---
title: "Create attachment and assign it to an existing call"
description: "POST /calls/{call_id}/attachments — Before creating an attachment, the file should be uploaded to S3. Make a request to `attachments/s3_form` for a pre-authorized upload form."
canonical_url: https://developer.onepagecrm.com/api/reference/calls/post-calls-call_id-attachments/
source: Markdown mirror of https://developer.onepagecrm.com/api/reference/calls/post-calls-call_id-attachments/
---

`POST /calls/{call_id}/attachments`

Before creating an attachment, the file should be uploaded to S3.  Make a request to `attachments/s3_form` for a pre-authorized upload form. Following successful upload to S3, files can be attached via this endpoint.

Resource: [Calls](https://developer.onepagecrm.com/api/reference/calls/) · [API Reference](https://developer.onepagecrm.com/api/reference/)

## Request

```bash
curl -X POST "https://app.onepagecrm.com/api/v3/calls/{call_id}/attachments" \
  -u $user_id:$api_key \
  -H "Content-Type: application/json" \
  -d '{
    "reference_id": "5afc1b69d556730b580596cb",
    "reference_type": "call",
    "contact_id": "5ae06ef9d55673108fe8877f",
    "name": "mario.jpg",
    "key": "5ae06ef9d55673108fe8877f/1530520812224/mario.jpg",
    "size": 3841,
    "external_url": ""
  }'
```

Authentication is HTTP Basic — `user_id` as username, `api_key` as password.
See https://developer.onepagecrm.com/api/authentication/.

## Path parameters

| Name | Type | Description |
| --- | --- | --- |
| `call_id` | string | Call ID |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `reference_id` | string (bson-id) |  | ID of the call associated with the attachment |
| `reference_type` | string | yes | Type of resource is associated with the attachment |
| `contact_id` | string (bson-id) |  | ID of the contact, to whom the note belongs |
| `name` | string |  | Name of the attachment file |
| `key` | string | yes | The same key used in the `attachments/s3_form`, composed as `{contact_id}/{timestamp}/{filename}` |
| `size` | integer (int32) |  | Size of the attachment file (in bytes) |
| `link_type` | string |  | Type of external link (for external `storage_provider`s) |
| `external_url` | string |  | URL for the file (for use with external `storage_provider`s) |

## Responses

### 201

Created

```json
{
  "status": 0,
  "message": "OK",
  "timestamp": 1528373119,
  "data": {
    "attachment": {
      "id": "5afc1ea9d556730b780096db",
      "filename": "mario.jpg",
      "custom_filename": "another_mario.jpg",
      "pinned": true,
      "pinned_at": "2022-01-24T10:42:39Z",
      "size": 3841,
      "storage_provider": "amazon",
      "url": "https://{foo.bar}/mario.jpg",
      "url_expires_at": "2018-05-16T13:06:53Z",
      "thumbnail": {
        "url": "https://{foo.bar}/mario-thumbnail.jpg"
      }
    }
  }
}
```

Standard error responses: 400, 401, 403, 404, 409, 500 — shared across the API. See https://developer.onepagecrm.com/api/errors/.

## Related guides

- [Authentication](https://developer.onepagecrm.com/api/authentication/)
- [Errors](https://developer.onepagecrm.com/api/errors/)
- [Rate limits](https://developer.onepagecrm.com/api/rate-limits/)
