> For the complete documentation index, see [llms.txt](https://help.sagexglobal.ai/sagex-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sagexglobal.ai/sagex-api/reference/api-reference/upload-document.md).

# Upload Document

## Upload Document to  Workspace

## Upload Document

<mark style="color:green;">`POST`</mark> `https://app.sagexglobal.ai/api/document/upload`

This is HTTPS Post method to upload the pdf document to be uploaded to your Account Workspace

**Authorization**

**Bearer Token : \<API key>**

The client must send this API Key in the Authorization header when making requests to protected resources

#### Request Body

| Name                                              | Type        | Description                            |
| ------------------------------------------------- | ----------- | -------------------------------------- |
| file<mark style="color:red;">\*</mark>            | file        | /path/file.pdf                         |
| realm\_guid<mark style="color:red;">\*</mark>     | Text        | Your account  realm id                 |
| workspace\_guid<mark style="color:red;">\*</mark> | Text        | Your account  workspace id             |
| document\_name<mark style="color:red;">\*</mark>  | Text        | Name of the document                   |
| document\_fields                                  | JSON Object | Refer below for details on JSON Object |

{% tabs %}
{% tab title="200 Document Successfully Uploaded" %}

```javascript
//Sample Response Body
{
    "data": {
        "realm_guid": "NN",
        "workspace_guid": "xxxxxx-c160-11ed-xxxxx-xxxxxxx",
        "document_guid": "xxxx-068f-xxxx-xxxx-xxxxxxx"
    },
    "message": "success",
    "status": "success",
    "code": 200
}
```

{% endtab %}

{% tab title="401 Permission denied" %}

{% endtab %}
{% endtabs %}

```
// document_fields - JSON Object
{ 
    "country" :"<iso country code>",
    "language": "<iso language code>",
    "document_ref": "<client generated unique document id>",
    "publishing_year": "<year of publishing the document>",
    "publisher_name": "<name of entity/person/business publishing the document>",
    "document_type": "<document type defined by organization>"
}	
```

Take a look at how you might call this method using `curl`:

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

```markup
curl -X POST 'https://app.sagexglobal.ai/api/document/upload' \
--form 'file=@"/path/file.pdf"' \
--form 'realm_guid="<realm_id>"' \
--form 'workspace_guid="<workspace_id>"' \
--form 'document_name="<document_name>"' \
--form 'document_fields="{
    \"country\": \"IND\",
    \"language\": \"En\"
}"'
-H "Authorization: Bearer <API Key>"
```

{% endtab %}
{% endtabs %}
