> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xenia.team/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload a File

> Get a presigned upload URL for a photo or file to attach to an action.

Attaching a file to an action takes two steps:

1. Call this endpoint with the file's name. It returns a presigned `url` and a file `key`.
2. `PUT` the file's bytes to `url`.

Then send the `key` in `attachments` on [Create Action](https://docs.xenia.team/api-reference/endpoints/actions/create-action.md) or [Complete Action](https://docs.xenia.team/api-reference/endpoints/actions/complete-action.md).

> [!NOTE]
>
> Actions must be enabled for your workspace. Contact Xenia to enable it. Until then, this endpoint returns `403` with "Actions are not enabled for this workspace."

This endpoint is open to client keys only in the workspace-scoped form shown above.

## Path parameters

**workspaceId** `string\<uuid\>` *required*

UUID of the workspace. Must be the workspace your API key is bound to.

## Body

**fileName** `string` *required*

The file's name, with an extension the app accepts: images, video, audio, PDF, Office and text documents, CSV, email, ZIP and 7z, and some CAD formats. SVG files and executables are refused. Spaces and characters such as `#`, `%`, `&`, `+`, and `?` are replaced with `_` in the returned `key`.

**mimeType** `string`

The file's content type, such as `image/jpeg`. Defaults to the type for the file's extension.

## Response

Returns `200` with `{ "data": { "url", "key" }, "meta": {} }`.

* `url` is a presigned upload URL. It's valid for 15 minutes.
* `key` is the file key to send in `attachments`.

## Uploading the file

`PUT` the file's bytes to `url`, with a `Content-Type` header that matches `mimeType` (or the type for the file's extension, if you didn't send one). Don't send your client key or secret: the URL is already signed.

```bash theme={null}
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: image/jpeg" \
  --data-binary @paint-aisle.jpg
```

## Errors

| Status | When |
| - | - |
| `401` | Invalid client credentials |
| `403` | Actions are not enabled for this workspace |
| `415` | The file type isn't allowed, such as "File type ".exe" is not allowed." |
| `422` | `fileName` is missing. This error has the body shown on the [Error handling](https://docs.xenia.team/guides/error-handling.md) page |
| `426` | The workspace has used up its file storage |

```bash cURL theme={null}
curl -X POST "https://api.xenia.team/api/v1/mgt/workspaces/{workspaceId}/media/create-signed-upload-url" \
  -H "x-client-key: YOUR_CLIENT_KEY" \
  -H "x-client-secret: YOUR_CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{ "fileName": "paint-aisle.jpg", "mimeType": "image/jpeg" }'
```

```json 200 theme={null}
{
  "data": {
    "url": "https://…/4a2e…/9d03…/1795200000000/paint-aisle.jpg?X-Amz-Algorithm=…&X-Amz-Signature=…",
    "key": "4a2e…/9d03…/1795200000000/paint-aisle.jpg"
  },
  "meta": {}
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.