# Upload attachment

`POST https://api.airtable.com/v0/{baseId}/{recordId}/{attachmentFieldIdOrName}/uploadAttachment`

Upload an attachment up to 5 MB to an attachment cell via the file bytes directly. 

To upload attachments above this size that are accessible by a public URL, they can be added using https://airtable.com/developers/web/api/field-model#multipleattachment

## Requirements

- **Authentication:** [Personal access token](https://airtable.com/developers/web/api/authentication.md#types-of-token), [OAuth integration](https://airtable.com/developers/web/api/authentication.md#types-of-token)
- **Scope:** [data.records:write](https://airtable.com/developers/web/api/scopes.md#data-records-write)
- **User role:** Base editor
- **Billing plans:** All plans

## Path parameters

- `baseId: string`

- `recordId: string`

- `attachmentFieldIdOrName: string`

## Request body

- `contentType: string` — required

  Content type, e.g. "image/jpeg"

- `file: string` — required

  The base64 encoded string of the file to be uploaded.

- `filename: string` — required

  Filename, e.g. "foo.jpg"

## Response format

- `id: string` — required

  Record ID

- `createdTime: string` — required

  A date timestamp in the ISO format, eg:"2018-01-01T00:00:00.000Z"

- `fields: object` — required

  Cell values are keyed by field ID.

  See [Cell Values](https://airtable.com/developers/web/api/field-model.md) for more information on cell value response types.

  - `[key: string]` — [Cell value](https://airtable.com/developers/web/api/field-model.md)

### Example — Upload a text file

```sh
curl -X POST "https://api.airtable.com/v0/{baseId}/{recordId}/{attachmentFieldIdOrName}/uploadAttachment" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
--data '{
    "contentType": "text/plain",
    "file": "SGVsbG8gd29ybGQ=",
    "filename": "sample.txt"
  }'
```

```json
{
  "createdTime": "2022-02-01T21:25:05.663Z",
  "fields": {
    "fld00000000000000": [
      {
        "filename": "sample.txt",
        "id": "att00000000000000",
        "size": 11,
        "type": "text/plain",
        "url": "https://v5.airtableusercontent.com/v3/u/29/29/1716940800000/ffhiecnieIwxisnIBDSAln/foDeknw_G5CdkdPW1j-U0yUCX9YSaE1EJft3wvXb85pnTY1sKZdYeFvKpsM-fqOa6Bnu5MQVPA_ApINEUXL_E3SAZn6z01VN9Pn9SluhSy4NoakZGapcvl4tuN3jktO2Dt7Ck_gh4oMdsrcV8J-t_A/53m17XmDDHsNtIqzM1PQVnRKutK6damFgNNS5WCaTbI"
      }
    ]
  },
  "id": "rec00000000000000"
}
```
