# File Retrieve (https://developers.doctavian.com/openapi/latest/reference/Signatures/envelope-signatures-file-retrieve)

## `GET /signatures/file/retrieve`

**File Retrieve**

Fetches a file from a public URL and returns its bytes, converting a `.docx` to PDF on the way — so a client can show a document from a link as a PDF without downloading and converting it itself. Send the address as `fileUrl`; any publicly reachable URL is accepted.

A PDF comes back unchanged and a `.docx` as a PDF. Anything else is returned as fetched — an HTML page comes back as HTML. The response is the file itself, not the standard JSON envelope, with `Content-Type` `application/octet-stream` and no `Content-Disposition` header, so name the file yourself.

A URL that cannot be fetched — not well-formed, on a host that does not resolve, or answering with an error such as `404` — is rejected with `400` `FILE_COULD_NOT_BE_RETRIEVED`. A request without `fileUrl` matches no operation and is answered with `404` `NOT_FOUND` from the gateway.

Send a bearer token. A call without one is rejected at the gateway with `401` `AUTHORIZATION_ERROR`; a recipient's `tid` is not accepted.

### Parameters
- `fileUrl` (query, string) **required** _(format: uri)_ — Absolute URL of the file to fetch, URL-encoded in the query string. Mandatory: leaving it out matches no operation and is answered with `404` `NOT_FOUND` from the gateway. Any publicly reachable URL is accepted; one that cannot be fetched is rejected with `400` `FILE_COULD_NOT_BE_RETRIEVED`.

### Responses

#### `200` — The file's bytes: a `.docx` converted to PDF, anything else as it was fetched.

`application/octet-stream`:

_any_

#### `400` — The file could not be fetched from `fileUrl` (`FILE_COULD_NOT_BE_RETRIEVED`): the URL is not well-formed, its host does not resolve, or it answered with an error such as `404`.

`application/json`:

- `error` (object) **required** — What went wrong. `statusCode` and `message` describe the failure category, `innerErrors` the specific causes.
  - `innerErrors` (array<object>) **required** — One entry per distinct problem found with the request. At least one entry is always present, and a request failing several checks reports each of them separately -- read the whole array rather than only the first entry.
    - `code` (string) **required** — Stable, machine-readable Doctavian error code identifying what went wrong, in SCREAMING_SNAKE_CASE. This is the field to branch on in code: the two message fields are prose and may be reworded, but a code, once published, keeps its meaning.
    - `message` (string) **required** — Technical explanation of this specific failure, written for developers and logs. May reference internal specifics and is not safe to show an end user -- use `userMessage` for anything user-facing.
    - `userMessage` (string) **required** — The same failure phrased for an end user and safe to display in a UI verbatim. Says what the user can do about the problem where there is something to do, and never exposes internal detail.
    - `urn` (string) — The request property this error concerns, when the error is about one property. Optional: most errors leave it out. Named by the property's server-side name in PascalCase, not the JSON field name — `TemplateName` for `template.templateName`. Not related to the `urn` that identifies a file elsewhere in the API.
    - `eventId` (string) _(format: uuid)_ — Identifier of the logged failure behind this entry. Present only when the failure was logged, so treat it as optional. Quote it together with `operationId` when reporting the problem to support.
  - `message` (string) **required** — Short summary of the failure category, mirroring the HTTP status text (e.g. `Bad Request`). It names the class of failure only; the specific cause is in `innerErrors`.
  - `statusCode` (integer) **required** — HTTP status code of the error, repeated inside the body so the envelope stays self-contained when it is logged or forwarded. Always a number, never a string, and always equal to the response's own HTTP status.
  - `externalErrors` (array<any>) — Additional error detail attached as the server produced it. Each entry can be any JSON value and its shape is not fixed: an object returned by an external service the request depended on — such as the Google Apps Script execution layer used for `gdoc`, `gsheet` and `gslide` generation — or a plain string, such as the message of an unhandled exception. Use it for diagnostics only, and branch on `innerErrors[].code` instead. Empty or absent when there is nothing to add.
- `dateTime` (string) **required** _(format: date-time)_ — UTC timestamp when the error response was generated, with between three and seven decimal places. Doctavian's own responses end in `Z`; a response from the gateway — a `401` for a missing or invalid credential, or a `404` for a request that matches no operation — has seven decimal places and ends in `+00:00` instead.
- `operationId` (string) — Identifier of this operation in Doctavian's Azure logs, generated per request and returned on both success and failure. This is the primary reference to quote when reporting a problem to support; when `eventId` is also present, quote both. Left out of a response from the gateway, which answers some requests before they reach Doctavian: a `401` for a missing or invalid credential, and a `404` for a request that matches no operation, such as one without a mandatory query parameter. Such a response has no operation to log, and its `origin` may be empty.
- `eventId` (string) _(format: uuid)_ — Identifier of the corresponding entry in Doctavian's server-side error log. Present only when the failure was handled and logged, so treat it as optional and don't rely on it being there. When reporting a problem to support, quote it together with `operationId`: `operationId` identifies the request that was made, `eventId` identifies the logged failure behind it, and having both is what lets support trace the request end to end. A failure can instead, or also, carry an `eventId` on individual `innerErrors` entries.
- `origin` (string) **required** — The HTTP method and full request URL that produced this response, e.g. `POST https://api.doctavian.com/v1/documents/document/generate`. Useful when the envelope is logged or forwarded away from the call that produced it.
- `userId` (string) _(format: uuid)_ — The unique identifier of the user or system that initiated the request. Left out of the response when the request carried no bearer token — a guest caller on an operation that does not require one, such as a recipient signing with a `tid` — because there is no signed-in user to identify. Also left out when the caller has no Doctavian user yet: `platform-subscription-resolve` and `platform-subscription-trial-start` run before the caller's user exists, so their responses carry no `userId`.
- `externalContext` (object) — Optional, arbitrary JSON object echoed back unchanged from the request's externalContext, if one was supplied. Used to correlate this response with the request that produced it.

#### `404` — `NOT_FOUND`: the request has no `fileUrl`, so it matches no operation. This response comes from the gateway before the request reaches the operation, so its `origin` is empty and it carries no `operationId` or `userId`.

`application/json`:

- `error` (object) **required** — What went wrong. `statusCode` and `message` describe the failure category, `innerErrors` the specific causes.
  - `innerErrors` (array<object>) **required** — One entry per distinct problem found with the request. At least one entry is always present, and a request failing several checks reports each of them separately -- read the whole array rather than only the first entry.
    - `code` (string) **required** — Stable, machine-readable Doctavian error code identifying what went wrong, in SCREAMING_SNAKE_CASE. This is the field to branch on in code: the two message fields are prose and may be reworded, but a code, once published, keeps its meaning.
    - `message` (string) **required** — Technical explanation of this specific failure, written for developers and logs. May reference internal specifics and is not safe to show an end user -- use `userMessage` for anything user-facing.
    - `userMessage` (string) **required** — The same failure phrased for an end user and safe to display in a UI verbatim. Says what the user can do about the problem where there is something to do, and never exposes internal detail.
    - `urn` (string) — The request property this error concerns, when the error is about one property. Optional: most errors leave it out. Named by the property's server-side name in PascalCase, not the JSON field name — `TemplateName` for `template.templateName`. Not related to the `urn` that identifies a file elsewhere in the API.
    - `eventId` (string) _(format: uuid)_ — Identifier of the logged failure behind this entry. Present only when the failure was logged, so treat it as optional. Quote it together with `operationId` when reporting the problem to support.
  - `message` (string) **required** — Short summary of the failure category, mirroring the HTTP status text (e.g. `Bad Request`). It names the class of failure only; the specific cause is in `innerErrors`.
  - `statusCode` (integer) **required** — HTTP status code of the error, repeated inside the body so the envelope stays self-contained when it is logged or forwarded. Always a number, never a string, and always equal to the response's own HTTP status.
  - `externalErrors` (array<any>) — Additional error detail attached as the server produced it. Each entry can be any JSON value and its shape is not fixed: an object returned by an external service the request depended on — such as the Google Apps Script execution layer used for `gdoc`, `gsheet` and `gslide` generation — or a plain string, such as the message of an unhandled exception. Use it for diagnostics only, and branch on `innerErrors[].code` instead. Empty or absent when there is nothing to add.
- `dateTime` (string) **required** _(format: date-time)_ — UTC timestamp when the error response was generated, with between three and seven decimal places. Doctavian's own responses end in `Z`; a response from the gateway — a `401` for a missing or invalid credential, or a `404` for a request that matches no operation — has seven decimal places and ends in `+00:00` instead.
- `operationId` (string) — Identifier of this operation in Doctavian's Azure logs, generated per request and returned on both success and failure. This is the primary reference to quote when reporting a problem to support; when `eventId` is also present, quote both. Left out of a response from the gateway, which answers some requests before they reach Doctavian: a `401` for a missing or invalid credential, and a `404` for a request that matches no operation, such as one without a mandatory query parameter. Such a response has no operation to log, and its `origin` may be empty.
- `eventId` (string) _(format: uuid)_ — Identifier of the corresponding entry in Doctavian's server-side error log. Present only when the failure was handled and logged, so treat it as optional and don't rely on it being there. When reporting a problem to support, quote it together with `operationId`: `operationId` identifies the request that was made, `eventId` identifies the logged failure behind it, and having both is what lets support trace the request end to end. A failure can instead, or also, carry an `eventId` on individual `innerErrors` entries.
- `origin` (string) **required** — The HTTP method and full request URL that produced this response, e.g. `POST https://api.doctavian.com/v1/documents/document/generate`. Useful when the envelope is logged or forwarded away from the call that produced it.
- `userId` (string) _(format: uuid)_ — The unique identifier of the user or system that initiated the request. Left out of the response when the request carried no bearer token — a guest caller on an operation that does not require one, such as a recipient signing with a `tid` — because there is no signed-in user to identify. Also left out when the caller has no Doctavian user yet: `platform-subscription-resolve` and `platform-subscription-trial-start` run before the caller's user exists, so their responses carry no `userId`.
- `externalContext` (object) — Optional, arbitrary JSON object echoed back unchanged from the request's externalContext, if one was supplied. Used to correlate this response with the request that produced it.

#### `500` — The file could not be returned because of an unhandled server-side failure (`FUNCTION_EXECUTION_ERROR`). When one is available, this response carries an `eventId` identifying the logged failure — quote it together with `operationId` when reporting the problem to support.

`application/json`:

- `error` (object) **required** — What went wrong. `statusCode` and `message` describe the failure category, `innerErrors` the specific causes.
  - `innerErrors` (array<object>) **required** — One entry per distinct problem found with the request. At least one entry is always present, and a request failing several checks reports each of them separately -- read the whole array rather than only the first entry.
    - `code` (string) **required** — Stable, machine-readable Doctavian error code identifying what went wrong, in SCREAMING_SNAKE_CASE. This is the field to branch on in code: the two message fields are prose and may be reworded, but a code, once published, keeps its meaning.
    - `message` (string) **required** — Technical explanation of this specific failure, written for developers and logs. May reference internal specifics and is not safe to show an end user -- use `userMessage` for anything user-facing.
    - `userMessage` (string) **required** — The same failure phrased for an end user and safe to display in a UI verbatim. Says what the user can do about the problem where there is something to do, and never exposes internal detail.
    - `urn` (string) — The request property this error concerns, when the error is about one property. Optional: most errors leave it out. Named by the property's server-side name in PascalCase, not the JSON field name — `TemplateName` for `template.templateName`. Not related to the `urn` that identifies a file elsewhere in the API.
    - `eventId` (string) _(format: uuid)_ — Identifier of the logged failure behind this entry. Present only when the failure was logged, so treat it as optional. Quote it together with `operationId` when reporting the problem to support.
  - `message` (string) **required** — Short summary of the failure category, mirroring the HTTP status text (e.g. `Bad Request`). It names the class of failure only; the specific cause is in `innerErrors`.
  - `statusCode` (integer) **required** — HTTP status code of the error, repeated inside the body so the envelope stays self-contained when it is logged or forwarded. Always a number, never a string, and always equal to the response's own HTTP status.
  - `externalErrors` (array<any>) — Additional error detail attached as the server produced it. Each entry can be any JSON value and its shape is not fixed: an object returned by an external service the request depended on — such as the Google Apps Script execution layer used for `gdoc`, `gsheet` and `gslide` generation — or a plain string, such as the message of an unhandled exception. Use it for diagnostics only, and branch on `innerErrors[].code` instead. Empty or absent when there is nothing to add.
- `dateTime` (string) **required** _(format: date-time)_ — UTC timestamp when the error response was generated, with between three and seven decimal places. Doctavian's own responses end in `Z`; a response from the gateway — a `401` for a missing or invalid credential, or a `404` for a request that matches no operation — has seven decimal places and ends in `+00:00` instead.
- `operationId` (string) — Identifier of this operation in Doctavian's Azure logs, generated per request and returned on both success and failure. This is the primary reference to quote when reporting a problem to support; when `eventId` is also present, quote both. Left out of a response from the gateway, which answers some requests before they reach Doctavian: a `401` for a missing or invalid credential, and a `404` for a request that matches no operation, such as one without a mandatory query parameter. Such a response has no operation to log, and its `origin` may be empty.
- `eventId` (string) _(format: uuid)_ — Identifier of the corresponding entry in Doctavian's server-side error log. Present only when the failure was handled and logged, so treat it as optional and don't rely on it being there. When reporting a problem to support, quote it together with `operationId`: `operationId` identifies the request that was made, `eventId` identifies the logged failure behind it, and having both is what lets support trace the request end to end. A failure can instead, or also, carry an `eventId` on individual `innerErrors` entries.
- `origin` (string) **required** — The HTTP method and full request URL that produced this response, e.g. `POST https://api.doctavian.com/v1/documents/document/generate`. Useful when the envelope is logged or forwarded away from the call that produced it.
- `userId` (string) _(format: uuid)_ — The unique identifier of the user or system that initiated the request. Left out of the response when the request carried no bearer token — a guest caller on an operation that does not require one, such as a recipient signing with a `tid` — because there is no signed-in user to identify. Also left out when the caller has no Doctavian user yet: `platform-subscription-resolve` and `platform-subscription-trial-start` run before the caller's user exists, so their responses carry no `userId`.
- `externalContext` (object) — Optional, arbitrary JSON object echoed back unchanged from the request's externalContext, if one was supplied. Used to correlate this response with the request that produced it.