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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://talque.gitbook.io/public/webhooks/file-upload.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
