> ## Documentation Index
> Fetch the complete documentation index at: https://docs.petal.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Document Creation

> How to upload your file to Petal

## Prerequisites

Before you can upload a file to Petal, you will need:

1. Your bearer token and desired Workspace ID. They can be obtained as described [here](/intro/credentials).
2. Software that can use APIs, such as cURL or Python.

## Upload a Document

The API endpoint for creating a Document is `https://cite.petal.org/api/document/create`. You will need to send a POST request to the endpoint with a `multipart/form-data` body containing three fields:

<ParamField path="organization_id" type="integer">
  The ID of your Workspace/Organization
</ParamField>

<ParamField path="doctype" type="string">
  The extension of your document, e.g. `pdf`, `docx`, `ppt`
</ParamField>

<ParamField path="file" type="binary">
  The file you wish to upload
</ParamField>

Below is an example of a Document creation POST request.

<Note>Remember to replace `<token>` with your own bearer token.</Note>

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request POST 'https://cite.petal.org/api/document/create' \
  --header 'Authorization: Bearer <token>' \
  --form 'doctype="xls"' \
  --form 'organization_id="1"' \
  --form 'file=@"/your/filepath/here/sample.xls"'
  ```

  ```python Python theme={null}
  import requests

  url = "https://cite.petal.org/api/document/create"

  payload={'doctype': 'xls', 'organization_id': '1'}
  files=[
    ('file',('sample.xls',open('/your/filepath/here/sample.xls','rb'),'application/vnd.ms-excel'))
  ]
  headers = {'Authorization': 'Bearer <token>'}

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

  print(response.text)

  ```

  ```java JavaScript theme={null}
  var form = new FormData();
  form.append("doctype", "xls");
  form.append("organization_id", "1");
  form.append("file", fileInput.files[0], "sample.xls");

  var settings = {
    "url": "https://cite.petal.org/api/document/create",
    "method": "POST",
    "timeout": 0,
    "headers": {
      "Authorization": "Bearer <token>"
    },
    "processData": false,
    "mimeType": "multipart/form-data",
    "contentType": false,
    "data": form
  };

  $.ajax(settings).done(function (response) {
    console.log(response);
  });
  ```
</CodeGroup>
