# Prepare an upload (/reference/api/uploads/prepare-upload)

```json
[
  {
    "method": "POST",
    "path": "/api/v1/uploads",
    "operationId": "prepareUpload",
    "tags": [
      "Uploads"
    ],
    "summary": "Prepare an upload",
    "description": "Reserves an upload and returns where to send the bytes. Pending uploads expire after 24 hours.",
    "x-required-scope": "documents:write",
    "security": [
      {
        "oauth": [
          "documents:write"
        ]
      },
      {
        "sessionCookie": []
      },
      {
        "secureSessionCookie": []
      }
    ],
    "responses": {
      "201": {
        "description": "Transfer descriptor. PUT bytes to url using every returned header, then POST /documents.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/PreparedUpload"
            }
          }
        }
      },
      "429": {
        "description": "Compute admission or usage is limited.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds until retry.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      },
      "default": {
        "description": "Request failed. Inspect error.code and error.message.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "requestBody": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "size": {
                "type": "integer",
                "minimum": 1
              },
              "lastModified": {
                "type": "integer",
                "minimum": 1
              },
              "author": {
                "type": "string"
              },
              "language": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "size"
            ]
          },
          "examples": {
            "file": {
              "summary": "Send a PDF",
              "value": {
                "name": "paper.pdf",
                "size": 482133
              }
            }
          }
        }
      }
    }
  }
]
```

## Components

```json
{
  "#/components/schemas/Error": {
    "type": "object",
    "properties": {
      "error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryAfterMs": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    },
    "required": [
      "error"
    ]
  },
  "#/components/schemas/PreparedUpload": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string",
        "format": "uuid"
      },
      "url": {
        "type": "string"
      },
      "headers": {
        "type": "object",
        "additionalProperties": {
          "type": "string"
        }
      },
      "expiresAt": {
        "type": "number"
      }
    },
    "required": [
      "id",
      "url",
      "headers",
      "expiresAt"
    ]
  }
}
```