# Submit Documents API (Legacy)

<table data-header-hidden><thead><tr><th width="74.8046875" align="center"></th><th></th></tr></thead><tbody><tr><td align="center"><mark style="color:blue;"><strong>POST</strong></mark> </td><td>https://api.sfox.com/v1/enterprise/ddq/upload</td></tr></tbody></table>

Submit a document or set of documents on behalf of an end user.&#x20;

***

#### Document Requirements

* The supported MIME types for document submission are `image/jpeg`, `image/png`, `application/pdf` .&#x20;
* File extension must be one of `jpg`, `jpeg`, `png`, `pdf`.
* File names specified in the `file_types` object must exactly match the file name attached in the `files` array. (e.g. `files` = `[.../id_front.png]` and `file_types` = `{"id_front.png":"ID"}`)
* A valid document type must be submitted with the file name in `file_types`. Options are:&#x20;
  * `ID`: Government issued IDs such as driver's licenses or passports.
  * `PoR`: Proof of residence documents such as bank statements or utility bills.

## Request

### Body Parameters (Form Data)

<table><thead><tr><th width="193.625">Parameter</th><th width="138.109375">Type</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>user_id</code></strong> <mark style="color:red;">required</mark></td><td>string</td><td>The unique user ID of the user that you are submitting a document or set of documents on behalf of.</td></tr><tr><td><strong><code>files</code></strong> <mark style="color:red;">required</mark></td><td>File[]</td><td>An array of the files you are uploading.  Note, each file must be 10MB or smaller.</td></tr><tr><td><strong><code>file_types</code></strong> <mark style="color:red;">required</mark></td><td>string <br><em>(JSON format)</em></td><td>The file name and document type of each file you are uploading in JSON format. e.g. <code>{"&#x3C;FILE_NAME>":"&#x3C;DOCUMENT_TYPE>"}</code><br> <br>File names MUST include the file extension and MUST exactly match the the corresponding file in <code>files</code>.<br><br><em>Possible document types: <code>ID</code>, <code>PoR</code></em></td></tr><tr><td><strong><code>ddq_id</code></strong> </td><td>string</td><td>The ID of the corresponding EDD request form that this submission is associated with.</td></tr></tbody></table>

### Example Requests

{% tabs %}
{% tab title="Shell" %}

```sh
// Submit a single document
curl --location 'https://api.sfox.com/v1/enterprise/ddq/upload' \
--header 'Authorization: Bearer ${ENTERPRISE_API_KEY}' \
--form 'files=@"${PATH_TO_FILE}"' \
--form 'user_id="${USER_ID}"' \
--form 'file_types="{\"${FILE_NAME}\":\"${DOCUMENT_TYPE}\"}"'
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
// Submit a single document
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('files', fs.createReadStream('${PATH_TO_FILE}'));
data.append('user_id', '${USER_ID}');
data.append('file_types', '{"${FILE_NAME}":"${DOCUMENT_TYPE}"}');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.sfox.com/v1/enterprise/ddq/upload',
  headers: { 
    'Authorization': 'Bearer ${ENTERPRISE_API_KEY}'
    ...data.getHeaders()
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
// Submit a single document
import requests

url = "https://api.sfox.com/v1/enterprise/ddq/upload"

payload = {'user_id': '${USER_ID}',
'file_types': '{"${FILE_NAME}":"${DOCUMENT_TYPE}"}'}
files=[
  ('files',('${FILE_NAME}',open('${PATH_TO_FILE}','rb'),'${MIME_TYPE}'))
]
headers = {
  'Authorization': 'Bearer ${ENTERPRISE_API_KEY}'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
```

{% endtab %}
{% endtabs %}

## Responses

<details>

<summary><mark style="color:green;"><strong><code>202</code></strong></mark> Accepted</summary>

```json
// Request accepted, files uploaded successfully
{
    "message": "Files uploaded successfully"
}
```

</details>

<details>

<summary><mark style="color:red;"><strong><code>401</code></strong></mark> Unauthorized</summary>

{% code overflow="wrap" %}

```json
// Invalid Enterprise API Key or not specified.
{
    "error": "invalid token. check authorization header."
}
```

{% endcode %}

</details>

<details>

<summary><mark style="color:red;"><strong><code>404</code></strong></mark>  Not Found</summary>

```json
// Invalid user_id or not specified
{
    "error": "user not found"
}
```

</details>

<details>

<summary><mark style="color:red;"><strong><code>422</code></strong></mark> Unprocessable Entity</summary>

{% code overflow="wrap" %}

```json
// Unsupported file type. The supported MIME types for document submission are image/jpeg, image/png, application/pdf.
{
    "error": "File extension <FILE_EXTENSION> is not allowed, invalid at file <FILE_NAME>"
}
```

{% endcode %}

{% code overflow="wrap" %}

```json
// Invalid file name in file_types. File name must include the file extension and exactly match files.
{
    "error": "Invalid file name <FILE_NAME>"
}
```

{% endcode %}

```json
// Invalid document type specified in file_types.
{
    "error": "Invalid file type <DOCUMENT_TYPE>, file_types must be one of PoR,ID"
}
```

{% code overflow="wrap" %}

```json
// Unsupported MIM type. The supported MIME types for document submission are image/jpeg, image/png, application/pdf.
{
    "error": "File mime type <TYPE> is not allowed, invalid at file <FILE_NAME>"
}
```

{% endcode %}

</details>

<details>

<summary><mark style="color:red;"><strong><code>500</code></strong></mark> Internal Server Error</summary>

{% code overflow="wrap" %}

```json
// Internal error
{
    "error": "An unknown error has occurred. If this persists, please contact support."
}
```

{% endcode %}

</details>


---

# 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://docs.sfox.com/connect/rest-api/end-users/submit-documents/submit-documents-api-legacy.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.
