---
agentTools:
  projectIndex: https://developer-docs.gomotive.com/llms.txt
---

# Create a new document

**Purpose**: Use this API to create a new document. You must specify values such as *Category, Document Type, Name, and Size* of the document in the Body Parameters. Refer to the **Body Parameters** section for more info.

If you are creating a document for a dispatch, you must upload the same document for your drivers to access. Take the following steps to upload the created document:

1. Use this API and ensure to pass the following body parameters:
   1. **Category**: Mention the category as 'dispatch'.
   2. **Dispatch ID**: Mention the corresponding dispatch ID.
      ```json Upload a document for a dispatch
      {
           "doc_name": "bill of lading",
           "doc_date": "2022-06-08",
           "category": "dispatch",
           "doc_type": "pdf",
           "doc_size": 5,
           "driver_id": 123,
           "dispatch_id": 40,
           "doc_time": "2022-06-08T21:54:56.601Z"
      }
      ```
2. Make the API call.\
   You will receive a response.
3. Copy the `upload_url`, and open the same in a browser.
4. Upload the document.
5. Now use the Update a specific document endpoint and add the following details:
   1. **ID (Path Parameter)**: Mention the ID of the document that you've just uploaded.
   2. **Status (Body Parameter)**: Mention the `upload_status`, as **completed**.\ <br />
      ```json Mark the document as Completed
      {
        "id":15310,
        "upload_status":"completed"
      }
      ```
      You have now successfully created a document for the dispatch as well as uploaded the same.

## Response Parameters

### document

* **Type**: Object
* **Description**: Details of the uploaded document.

### id

* **Type**: Integer
* **Description**: The unique identifier for the document.

### category

* **Type**: String
* **Description**: The category of the document, e.g., "other".

### upload\_url

* **Type**: String
* **Description**: The URL where the document is to be uploaded.

### ref\_no

* **Type**: String
* **Description**: The reference number associated with the document.

### notes

* **Type**: String
* **Description**: Notes associated with the document.

### doc\_date

* **Type**: Date (YYYY-MM-DD)
* **Description**: The date the document was created.

### doc\_fields

* **Type**: Array of Objects (nullable)
* **Description**: Custom fields associated with the document.

### doc\_time

* **Type**: DateTime (ISO 8601)
* **Description**: The time the document was created.

***

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Motive",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.gomotive.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/documents": {
      "post": {
        "summary": "Create a new document",
        "description": "",
        "operationId": "create-a-new-document",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "doc_name",
                  "doc_date",
                  "category",
                  "doc_type",
                  "doc_size"
                ],
                "properties": {
                  "doc_name": {
                    "type": "string",
                    "description": "Specify the name of the document that you are creating."
                  },
                  "doc_date": {
                    "type": "string",
                    "description": "Specify the date of the document that you are creating.",
                    "format": "date"
                  },
                  "category": {
                    "type": "string",
                    "description": "Specify the category of the document. Allowed values are \"dispatch\", or \"other\"."
                  },
                  "doc_type": {
                    "type": "string",
                    "description": "Specify the type of the document that you are creating. Allowed values are: 'png', 'jpeg', 'jpg', 'pdf'"
                  },
                  "doc_size": {
                    "type": "integer",
                    "description": "Specify the size of the document that you are creating.",
                    "format": "int32"
                  },
                  "driver_id": {
                    "type": "integer",
                    "description": "Specify the ID of the driver for whom you are creating this document. After the creating, the document will sent to the corresponding driver.",
                    "format": "int32"
                  },
                  "ref_no": {
                    "type": "string",
                    "description": "Specify the reference number or the order number that will be attached to the document."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Mention any notes for the document. For example, if you are sending a Dispatch related document, you can mention, Dispatch # XXXXX document for Driver # XXXXX."
                  },
                  "dispatch_id": {
                    "type": "integer",
                    "description": "If the category of the document is 'dispatch\", then you must mention the Dispatch ID as well.",
                    "format": "int32"
                  },
                  "doc_time": {
                    "type": "string",
                    "description": "The timestamp on the document.",
                    "format": "date"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Create a new document.": {
                    "value": "  {\n    \"document\": {\n        \"id\": 15310,\n        \"category\": \"other\",\n        \"upload_url\": \"https://gomotive-production.s3.amazonaws.com/uploads/document/doc_upload/15310/dispatch.png?X-Amz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Q06QXMlg4VN9nMhyQHE%2FecTzUQKhlKpRdCLgTuylz9%2FGY55dB1sWCMxC134Xd9kKNvfNQqgVk7PYoVaIRdMEWsH29UybZyk1QnSUa9s3XbF3viEz%2F8PSg9pbuSQ3hLHbf7k8Mht7iq0EdWOSDg%3D%3D&X-Amz-SignedHeaders=host&X-Amz-Signature=050cea35e805b70cb8fd4f5379b37c4b36073fcc623d2e3b00a95d633a37d502\",\n        \"ref_no\": \"89ABC89\",\n        \"notes\": \"example\",\n        \"doc_date\": \"2020-04-03\",\n        \"doc_fields\": null\n        \"doc_time\": \"2020-04-03T15:00:00Z\",\n    }\n}"
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Document URL": {
                    "value": "{\n  \"error_message\": \"document url cannot be formed\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "document url cannot be formed"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "403",
            "content": {
              "application/json": {
                "examples": {
                  "Invalid API Key": {
                    "value": "{\n  \"error_message\": \"invalid API key\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error_message": {
                      "type": "string",
                      "example": "invalid API key"
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "66acf64a829e88001980fbf2:66d1d0146335c1001031e72c"
}
```