AthausDoku

Upload a file

Aufruf, Parameter, Antwort und Fehler von POST /v1/medias.

Zuletzt aktualisiert:

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.

Braucht den Scope propose und mindestens die Stufe write auf files.

Aufruf

POST https://api.athaus.ai/v1/medias

Parameter

Abfrage

NameTypPflichtBeschreibung
fileNamestringneinThe name the file keeps in the app and in downloads. Without it the file is named file plus its type's ending.
kindstringneinWhat 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. Eines von photo, floor_plan, document.
documentTypestringneinFor 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.
externalMediaIdstringneinYour 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.

Kopf

NameTypPflichtBeschreibung
Athaus-VersionstringneinOptional 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-KeystringneinMakes 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.

Beispiel

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

Antwort

Bei Erfolg kommt 201 mit Media.

Media

FeldTypBeschreibung
objectstringImmer 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.
kindstringEines von 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)

Köpfe der Antwort

KopfBeschreibung
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.

Fehler

Jeder Fehler kommt als Problem Details. Verzweige auf code, nicht auf title oder detail.

StatusCodesBedeutung
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.

Weiter lesen

Auf dieser Seite