> For the complete documentation index, see [llms.txt](https://talque.gitbook.io/public/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://talque.gitbook.io/public/webhooks/file-upload.md).

# File upload

Some APIs require you to upload binary data, like images or documents. In order to efficiently transfer such additional data we do not embed them in the JSON request body, but provide a separate API to only upload the binary data. This API returns a temp file identifier, which you can then use to refer to the file in the JSON request body of subsequent API calls.

{% hint style="warning" %}
The returned temp file id expires after one week, so you should not store it in your database but only use for immediate API calls.
{% endhint %}

In order to upload a binary file you have to make two HTTP requests. First, create a signed upload URL:

## Create a new temp file identifier

<mark style="color:green;">`POST`</mark> `https://www.talque.com/webhook/file/temp/create`

Create a new temp file id and associated signed upload URL. This API call requires authentication as described in the Authentication section.

**Body**

There is no input, so the request body is an empty `{}` object.

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "tempFileId": "NL3bI9SZBaEalxdIpre4", 
    "uploadUrl": "https://storage.googleapis.com/...", 
    "success": true, 
    "reasonEnum": "CreateTempFileWebhookReason", 
    "reason": "SUCCESS"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

The returned value is a JSON dictionary that includes the `tempFileId` and `uploadUrl`. The second and final step is to upload the file content to the provided upload URL with a HTTP PUT request. For example, on the command line this could be done with the CURL command

```bash
curl -v --upload-file test.pdf 'https://storage.googleapis.com/...'
```

After the upload completes you can start using the temp file id in subsequent API calls.
