AthausDocs

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/medias

Parameters

Query

NameTypeRequiredDescription
fileNamestringnoThe name the file keeps in the app and in downloads. Without it the file is named file plus its type's ending.
kindstringnoWhat 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.
documentTypestringnoFor 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.
externalMediaIdstringnoYour 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

NameTypeRequiredDescription
Athaus-VersionstringnoOptional 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-KeystringnoMakes 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 @file

Response

On success the status is 201 with Media.

Media

FieldTypeDescription
objectstringAlways media.
idstring (uuid)UUID of the file. It stays the id of the file in /files once a listing has taken it.
externalMediaIdstringThe id a listing names in media[].externalMediaId.
kindstringOne of photo, floor_plan, document.
documentTypestring | null
fileNamestring
mimeTypestring
sizeBytesinteger
widthinteger | nullIn pixels, for an image where it is known.
heightinteger | nullIn pixels, for an image where it is known.
createdAtstring (date-time)

Response headers

HeaderDescription
Request-IdIdentifies this request. Quote it in a support request.
Athaus-VersionThe API version of this response: v1.
Athaus-ReleaseThe release of v1 that answered, for example 1.0. A label for support and changelogs; no request can select it.
RateLimit-PolicyThe quota policy of the bucket that applies.
RateLimitRemaining quota and seconds until the bucket is full again.
Idempotent-Replayedtrue 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.

StatusCodesMeaning
400invalid_query, api_version_unsupported, invalid_bodyInvalid request.
401unauthorizedMissing or invalid API key.
403insufficient_permissions, plan_requiredThe key lacks a right, or the plan does not include API access.
404not_foundNothing under this ID.
409reference_already_exists, idempotency_key_in_use, idempotency_outcome_unknownThe request conflicts with the state of the resource (for example a duplicate), or with an idempotency key.
413payload_too_largeThe file is larger than 25 MB.
415invalid_inputThe 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.
422idempotency_key_reusedThe idempotency key was already used with a different request body.
429rate_limitedRate limit exceeded.
500internal_errorServer error.

Keep reading

On this page