<!-- Generated from the canonical 99 Digital API documentation. Do not edit this file. -->

Canonical page: https://docs.99digital.co.il/online-api/contacts/files/upload-contact-file

# Upload Contact File

`POST https://online.99digital.co.il/api/v1/accounts/{account_id}/contacts/{contact_id}/add_file`

Attach a document to a contact's profile.

Documents attached to a contact profile (for example contracts or ID scans), with an optional comment.

| Action | Method | Path |
| --- | --- | --- |
| Upload a file | `POST` | `/api/v1/accounts/{account_id}/contacts/{contact_id}/add_file` |

**Authorization**: user token. Listing requires the [Retrieve Contact](https://docs.99digital.co.il/online-api/contacts/retrieve-contact) permission (new rules: **Contacts → read**). Uploading, updating and deleting require the [Update Contact](https://docs.99digital.co.il/online-api/contacts/update-contact) permission (new rules: **Contacts → update**). Legacy roles: any agent. Agent-bot tokens: not allowed.

**Upload (form-data) parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | file | Yes | Up to 10 MB. Allowed types: PDF, CSV, RTF, DOC/DOCX, XLS/XLSX, PNG, JPEG. The account's upload policy may restrict this further (for example, `text/plain` can be rejected). |
| `comment` | string | No | Comment stored with the file (max 500 characters on update). |

#### Example: upload a file

```bash
curl -X POST 'https://online.99digital.co.il/api/v1/accounts/12/contacts/801/add_file' \
  -H 'api_access_token: <YOUR_API_ACCESS_TOKEN>' \
  -F 'file=@invoice.png;type=image/png' \
  -F 'comment=Invoice for order A-1001'
```

Response (`200 OK`): **all** files of the contact.

```json
[
  {
    "id": 3101,
    "data_url": "https://online.99digital.co.il/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MzIwMX19--b7c1/invoice.png",
    "file_type": "image",
    "thumb_url": "https://online.99digital.co.il/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MzIwMX19--b7c1/invoice.png",
    "comment": "Invoice for order A-1001",
    "created_at_exact": "12/11/26 08:00"
  }
]
```

`file_type` is `image`, `audio`, `video` or the file's MIME type. `thumb_url` is returned only for images.

**Error responses (upload)**

| Status | When | Body |
| --- | --- | --- |
| `422` | No `file` sent. | `"File field is required"` |
| `415` | File type not allowed. | `File type is not supported: text/plain` |
| `413` | File larger than 10 MB. | Error message |

## Remarks

- The code samples add the file once you choose one under **Request → Body**.
- To change the comment later, use [Update Contact File](https://docs.99digital.co.il/online-api/contacts/files/update-contact-file).

## Authentication

`api_access_token` in the header — Your access token. A user token is in the dashboard under **Profile settings → Access Token**, and grants exactly what that agent's role allows. An agent-bot token may call only the endpoints marked for agent bots. See [Getting Started](https://docs.99digital.co.il/online-api/getting-started#authentication).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `account_id` | path | integer | Yes | The numeric ID of your account: the number after `/app/accounts/` in the dashboard URL. Example: `12`. |
| `contact_id` | path | integer | Yes | The numeric ID of the contact. Example: `801`. |

## Request body

Content type: `multipart/form-data` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | string (binary) | Yes | The file, up to 10 MB: PDF, CSV, RTF, DOC/DOCX, XLS/XLSX, PNG or JPEG. The account's upload policy may allow fewer types. |
| `comment` | string | No | An optional comment kept with the file. You can change it later with [Update Contact File](https://docs.99digital.co.il/online-api/contacts/files/update-contact-file), which accepts up to 500 characters. Example: `Invoice for order A-1001`. |

## Responses

### 200 — All the contact's files, including the new one.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `[].id` | integer | The file ID. |
| `[].data_url` | string | The URL of the file. |
| `[].file_type` | string | `image`, `audio`, `video`, or the file's MIME type (for example `application/pdf`). |
| `[].thumb_url` | string | The URL of a thumbnail. Returned for images only. |
| `[].comment` | string | The comment kept with the file. |
| `[].created_at_exact` | string | When the file was uploaded, as `DD/MM/YY HH:mm` (for example `12/11/26 08:00`). |

#### Example

```json
[
  {
    "id": 3101,
    "data_url": "https://online.99digital.co.il/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MzIwMX19--b7c1/invoice.png",
    "file_type": "image",
    "thumb_url": "https://online.99digital.co.il/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MzIwMX19--b7c1/invoice.png",
    "comment": "Invoice for order A-1001",
    "created_at_exact": "12/11/26 08:00"
  }
]
```

### 401 — The access token is missing or wrong, or its user does not belong to this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: Invalid token

The api_access_token header is missing or wrong.

```json
{
  "error": "Invalid Access Token"
}
```

#### Example: Another account

A valid token, for a user who is not in this account.

```json
{
  "error": "You are not authorized to access this account"
}
```

### 403 — The token's role does not have the permission this endpoint needs, or the endpoint is not open to agent-bot tokens. See [Authorization](https://docs.99digital.co.il/online-api/getting-started#authorization).

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: No permission

The role lacks the permission.

```json
{
  "error": "You are not authorized to do this action"
}
```

#### Example: Agent bot

An agent-bot token on an endpoint that is not open to bots.

```json
{
  "error": "Access to this endpoint is not authorized for bots"
}
```

### 404 — The resource does not exist in this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example

```json
{
  "error": "Resource could not be found"
}
```

### 413 — The file is larger than 10 MB.

### 415 — The file type is not allowed.

Content type: `text/plain`

Type: `string`.

#### Example

```text
File type is not supported: text/plain
```

### 422 — No `file` was sent.

Content type: `application/json`

Type: `string`.

#### Example

```json
"File field is required"
```
