Upload a file
Request, parameters, response and errors of POST /v1/medias.
Last updated:
Stores one photo, floor plan or document and returns its id. The body is the file itself, not JSON: Content-Type is its type (image/jpeg, image/png, image/webp, application/pdf), at most 25 MB. The query says what the file is: kind (photo, floor_plan, document), documentType for a document, fileName, and your own externalMediaId. The file belongs to no listing yet: name its externalMediaId in media when you create or change a listing, in the order you want. A file no listing names is removed after 7 days. The content must be of the type the header names (415 otherwise). Send Idempotency-Key to make a retry safe. Needs write access to files.
Requires the scope propose and at least the level write on files.
Request
POST https://api.athaus.ai/v1/mediasParameters
Query
| Name | Type | Required | Description |
|---|---|---|---|
fileName | string | no | The name the file keeps in the app and in downloads. Without it the file is named file plus its type's ending. |
kind | string | no | What the file is. Without it an image is a photo and a PDF a document. A photo must be an image; a floor_plan may be an image or a PDF. One of photo, floor_plan, document. |
documentType | string | no | For a document, which paper it is, in the keys the app uses: energy_certificate, floor_plan, living_area, land_registry, declaration_of_division, budget_plan, logs, utilities, lease, property_tax, expose, modernization, other. Not allowed for other kinds. |
externalMediaId | string | no | Your id of the file, which a listing names in media[].externalMediaId. Unique in the office. Without it Athaus uses the id it returns. 1 to 200 characters: letters, digits, ., _, : and -, starting with a letter or digit. |
Header
| Name | Type | Required | Description |
|---|---|---|---|
Athaus-Version | string | no | Optional and carries nothing a client needs: the version is the path. Accepted when it says v1 or 1. Any other value is a 400 api_version_unsupported. |
Idempotency-Key | string | no | Makes a retry safe: the same key with the same body returns the first answer and writes nothing twice. A random value of at least 128 bits, for example a UUID, 1 to 255 characters. The key is kept for 24 hours and scoped to the API key and this operation. The same key with a different body is a 422; while the first request still runs it is a 409. Only successful answers are kept: after an error the key is free again. |
Example
curl -X POST "https://api.athaus.ai/v1/medias" \
-H "Authorization: Bearer ath_live_..." \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: image/jpeg" \
--data-binary @fileResponse
On success the status is 201 with Media.
Media
| Field | Type | Description |
|---|---|---|
object | string | Always media. |
id | string (uuid) | UUID of the file. It stays the id of the file in /files once a listing has taken it. |
externalMediaId | string | The id a listing names in media[].externalMediaId. |
kind | string | One of photo, floor_plan, document. |
documentType | string | null | |
fileName | string | |
mimeType | string | |
sizeBytes | integer | |
width | integer | null | In pixels, for an image where it is known. |
height | integer | null | In pixels, for an image where it is known. |
createdAt | string (date-time) |
Response headers
| Header | Description |
|---|---|
Request-Id | Identifies this request. Quote it in a support request. |
Athaus-Version | The API version of this response: v1. |
Athaus-Release | The release of v1 that answered, for example 1.0. A label for support and changelogs; no request can select it. |
RateLimit-Policy | The quota policy of the bucket that applies. |
RateLimit | Remaining quota and seconds until the bucket is full again. |
Idempotent-Replayed | true when this is the stored answer to an earlier request with the same Idempotency-Key. |
Errors
Every error arrives as problem details. Branch on code, not on title or detail.
| Status | Codes | Meaning |
|---|---|---|
400 | invalid_query, api_version_unsupported, invalid_body | Invalid request. |
401 | unauthorized | Missing or invalid API key. |
403 | insufficient_permissions, plan_required | The key lacks a right, or the plan does not include API access. |
404 | not_found | Nothing under this ID. |
409 | reference_already_exists, idempotency_key_in_use, idempotency_outcome_unknown | The request conflicts with the state of the resource (for example a duplicate), or with an idempotency key. |
413 | payload_too_large | The file is larger than 25 MB. |
415 | invalid_input | The Content-Type is not one of image/jpeg, image/png, image/webp, application/pdf, or the bytes are not of the type the header names. |
422 | idempotency_key_reused | The idempotency key was already used with a different request body. |
429 | rate_limited | Rate limit exceeded. |
500 | internal_error | Server error. |
Keep reading
REST API: authentication with an API key
Every call to /v1 carries an API key as a bearer token. Where to get one, which scopes it carries and what does not work.
REST API: errors as problem details
Every error from /v1 is an RFC 9457 problem with a real HTTP status, a code to branch on and a request id for support.