Een vertaling maken
Create a translation using exactly one source: JSON content for verbatim UTF-8 text, JSON file_url for an HTTPS download without redirects, JSON upload_id for a completed temporary upload on this same credential, or multipart/form-data with a file field for local bytes that are binary, not UTF-8, or over 1 MB. Omit filename with upload_id; the session already owns its name. Repeating an upload_id returns the existing batch without changing its instruction. Send an Idempotency-Key header (any 1 to 255 printable characters, a UUID is fine) on the other sources to make a retry after a lost response safe: a repeat returns the batch the first attempt created, without fetching or storing the file or planning again, and the same key with different content is refused with 409 idempotency_key_reused. Otherwise filename is optional and inferred if absent. Include instruction to receive the verified plan, measured counts, credit cost and extraction preview; omit it to receive suggested_instructions. Check plan.not_included before approval. Creating and planning cost no credits. Per-format limits are on GET /v1/account. The translation appears in the web app.
POST/v1/batches
Hiervoor is batches:create vereist. Een vertaling maken kost niets: credits worden pas gereserveerd wanneer je een plan goedkeurt.
Een manier kiezen om het bestand te versturen
Kies de transportmethode die past bij de locatie van het document en de mogelijkheden van je client.
| Transport | Gebruik voor | Opmerkingen |
|---|---|---|
JSON met upload_id | Een lokaal bestand dat via een tijdelijke uploadsessie wordt verstuurd | Gebruik dezelfde inloggegevens als voor het aanmaken van de sessie. Laat filename weg. Als je de vertaling opnieuw aanmaakt, krijg je de bestaande vertaling terug zonder dat de instructie wordt gewijzigd. |
JSON met content | Elk tekstformaat | Het bestand zelf als UTF-8-tekst. De eenvoudigste optie voor een agent die de inhoud al in het geheugen heeft. |
JSON met file_url | Een bestand dat al ergens is gehost | Alleen HTTPS; het bestand wordt aan de serverzijde opgehaald. Er worden geen omleidingen gevolgd, dus geef de definitieve URL op. |
multipart/form-data | Lokale binaire bestanden, waaronder XLSX, DOCX, PPTX, PDF, IDML en ZIP | Verstuur de oorspronkelijke bytes in het veld file. Dit is de transportmethode voor lokale bestanden van de CLI. |
filename is optioneel, maar het is verstandig om deze mee te sturen. De extensie bepaalt hoe het formaat wordt herkend. Zo worden identieke bytes met de naam strings.xml en export.csv door verschillende parsers verwerkt.
Veilig opnieuw proberen
Stuur een Idempotency-Key-header mee (1 tot 255 afdrukbare tekens; een UUID is een goede keuze). Als een antwoord verloren gaat, levert een nieuwe poging dan de vertaling op die bij de eerste poging is aangemaakt, in plaats van een tweede vertaling. Een herhaalde aanvraag wordt afgehandeld voordat het bestand wordt opgehaald of opgeslagen en leidt niet opnieuw tot een plan, dus kost niets. De sleutel is gekoppeld aan wat je hebt verstuurd: als je dezelfde sleutel gebruikt met een ander bestand, een andere naam of een andere instructie, wordt de aanvraag geweigerd met idempotency_key_reused. Gebruik voor nieuw werk een nieuwe sleutel. Als headers niet beschikbaar zijn (MCP-tools, Code Mode), geef je idempotency_key mee in de body. Een aanvraag met een instruction retourneert plan_revision met het plan. Geef deze waarde door als expected_plan_revision wanneer je het plan goedkeurt.
Wat gebeurt er daarna?
De response bevat een id, dat je in volgende paden gebruikt als batch_id. Daarna is de volgorde altijd hetzelfde:
POST /v1/batches/{batch_id}/plan: beschrijf in je eigen woorden wat er vertaald moet worden.POST /v1/batches/{batch_id}/approve: gebruik credits en start de vertaling.GET /v1/batches/{batch_id}: controleer de status totdat de vertaling klaar is.GET /v1/batches/{batch_id}/result: haal het resultaat op. Dit retourneert een ondertekende link, niet het bestand zelf.
Autorisaties
Authorizationbearerin headerrequiredBody
application/jsonrequiredupload_idstring<uuid>pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$A completed temporary upload created by this same credential. Mutually exclusive with content and file_url.
file_urlstring<uri>length: ≤ 2000 charscontentstringlength: ≥ 1 charsfilenamestringlength: 1–200 charspattern: ^[^\/]+$instructionstringlength: 1–2000 charsidempotency_keystringlength: 1–255 charsNames this attempt so a retry after a lost response returns the batch the first attempt created instead of making a second one (and planning twice). 1 to 255 printable ASCII characters. Equivalent to the Idempotency-Key header, which takes precedence; use this field where headers are not available (MCP tools, Code Mode). A repeat is answered before any file is fetched or stored. The key is bound to what was sent (file, name and instruction): the same key with different content is refused with 409 idempotency_key_reused. Use a new key for new work.
Antwoord
Create a translation from a file
dataobjectrequiredrequest_idstringrequiredPossible codes: invalid_request, unknown_field, invalid_parameter, invalid_cursor
errorobjectrequiredrequest_idstringrequiredPossible codes: authentication_required, invalid_api_key, api_key_expired, api_key_revoked
errorobjectrequiredrequest_idstringrequiredPossible codes: insufficient_credits
errorobjectrequiredrequest_idstringrequiredPossible codes: insufficient_scope, feature_not_available, admin_required, file_retention_expired
errorobjectrequiredrequest_idstringrequiredPossible codes: batch_not_found, glossary_not_found, resource_not_found
errorobjectrequiredrequest_idstringrequiredPossible codes: glossary_already_exists, result_not_ready, batch_not_editable, idempotency_key_reused, no_plan_yet, plan_changed, batch_not_awaiting_approval
errorobjectrequiredrequest_idstringrequiredPossible codes: file_expired
errorobjectrequiredrequest_idstringrequiredPossible codes: request_too_large, file_too_large, result_too_large
errorobjectrequiredrequest_idstringrequiredPossible codes: language_not_supported, invalid_language_pair, glossary_term_limit_reached, glossary_limit_reached, invalid_glossary_terms, unsupported_format, file_fetch_failed, plan_invalid
errorobjectrequiredrequest_idstringrequiredPossible codes: rate_limited
errorobjectrequiredrequest_idstringrequiredPossible codes: internal_error
errorobjectrequiredrequest_idstringrequiredPossible codes: service_unavailable
errorobjectrequiredrequest_idstringrequired