# Set Document

{% hint style="info" %}
**URL Base**:

* UAT: <mark style="color:blue;">`https://api.cadastro.uat.unico.app`</mark>.
* Production: <mark style="color:blue;">`https://api.cadastro.unico.app`</mark>.
  {% endhint %}

***

## Set Process Document

> Endpoint to set the identification document on a process created without a document. Once defined, the document is immutable. Only available for processes whose Custom Flow allows creation without a document.

```json
{"openapi":"3.0.0","info":{"title":"SetDocument","version":"1.0.0"},"servers":[{"url":"https://api.cadastro.uat.unico.app"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"paths":{"/client/v1/process/{processId}/document":{"post":{"summary":"Set Process Document","description":"Endpoint to set the identification document on a process created without a document. Once defined, the document is immutable. Only available for processes whose Custom Flow allows creation without a document.","parameters":[{"name":"processId","in":"path","required":true,"description":"Process ID.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["duiType","duiValue"],"properties":{"duiType":{"type":"string","enum":["DUI_TYPE_BR_CPF","DUI_TYPE_MX_CURP","DUI_TYPE_US_SSN"],"description":"Identification document type. Possible values: 'DUI_TYPE_BR_CPF' - Brazilian CPF; 'DUI_TYPE_MX_CURP' - Mexican CURP; 'DUI_TYPE_US_SSN' - United States SSN."},"duiValue":{"type":"string","description":"Identification document value, without formatting."}}}}}},"responses":{"200":{"description":"Document successfully set on the process.","content":{"application/json":{"schema":{"type":"object","properties":{"process":{"type":"object","description":"Process information after setting the document.","properties":{"id":{"type":"string","description":"Process ID."},"person":{"type":"object","description":"Person information of the process.","properties":{"duiType":{"type":"string","description":"Identification document type."},"duiValue":{"type":"string","description":"Identification document value."}}}}}}}}}},"400":{"description":"When the request payload is invalid (missing fields, invalid duiType, malformed duiValue).","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer","description":"Error code."},"message":{"type":"string","description":"Error description."},"details":{}}}}}},"401":{"description":"Access-token error.","content":{"application/json":{"schema":{"type":"string","description":"Error description."}}}},"404":{"description":"When the process could not be found.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer","description":"Error code."},"message":{"type":"string","description":"Error description."},"details":{}}}}}}}}}}}
```

{% hint style="warning" %}

* Immutable Document: The document is immutable; once provided (either during process creation or through this endpoint), it cannot be changed.
* Process Status: The process must not be finalized or expired at the time of the call.
* Formatting: The value sent in `duiValue` must follow the format of the type specified in `duiType`, without periods, hyphens, or any other formatting (plain text only).
  {% endhint %}

{% hint style="success" %}
**Tips**:

* Monitoring: After receiving a success response from this endpoint, use the Get Process Result endpoint to track the final outcome, or configure Webhooks to be notified when the process is completed.
  {% endhint %}

### Errors

{% tabs %}
{% tab title="400 Bad Request" %}

<table><thead><tr><th width="85">code</th><th width="309.34375">message</th><th width="348.703125">description</th></tr></thead><tbody><tr><td>3</td><td><code>process id is invalid</code></td><td>When the process id is invalid.</td></tr><tr><td>3</td><td><code>dui_type is required</code></td><td>When the document type is not provided.</td></tr><tr><td>3</td><td><code>dui_value is required</code></td><td>When the document number is not provided.</td></tr><tr><td>3</td><td><code>dui_value exceeds maximum length</code></td><td>When the document number exceeds the maximum character limit.</td></tr><tr><td>9</td><td><code>process is not awaiting for document</code></td><td>When the specified process does not accept document submission.</td></tr><tr><td>9</td><td><code>process expired</code></td><td>When the specified process has expired.</td></tr><tr><td>9</td><td><code>document already set, cannot be modified</code></td><td>When the process already has a linked document.</td></tr><tr><td>9</td><td><code>process already finished</code></td><td>When the process has already been finalized.</td></tr><tr><td>9</td><td><code>flow does not allow optional document</code></td><td>When the document is mandatory for the flow executed by the process.</td></tr></tbody></table>
{% endtab %}

{% tab title="404 Not Found" %}

<table data-header-hidden><thead><tr><th width="88.04296875">code</th><th width="375.81640625">message</th><th>descrição</th></tr></thead><tbody><tr><td>5</td><td><code>error getting process: rpc error: code = NotFound desc = process not found</code></td><td>When the process ID was not found.</td></tr></tbody></table>
{% endtab %}

{% tab title="429 Too Many Requests " %}
No detailed error code will be provided for this situation, only the HTTP status code.
{% endtab %}

{% tab title="500 Internal Server Error" %}

<table><thead><tr><th width="99">code</th><th width="316.09765625">message</th><th>Descrição</th></tr></thead><tbody><tr><td>99999</td><td><code>Internal failure! Try again later</code></td><td>When an internal error occurs.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}


---

# 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://devcenter.unico.io/unico-idcloud/by-unico-integration/by-unico-api/api-reference/set-document.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.
