# Create a file upload intent

## `POST /v1/files/intents`

Upload the bytes to the signed transfer URL, then finalize the file before referencing it. Requires the `write` scope.

```json
{
  "tags": [
    "Files"
  ],
  "operationId": "create-file-intent",
  "summary": "Create a file upload intent",
  "description": "Upload the bytes to the signed transfer URL, then finalize the file before referencing it. Requires the `write` scope.",
  "x-retainer-scope": "write",
  "parameters": [
    {
      "in": "header",
      "name": "Idempotency-Key",
      "schema": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "description": "Reuse the same key with the same request to retry.",
      "required": true
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "mediaType": {
              "type": "string",
              "maxLength": 150,
              "pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*\\/[a-z0-9][a-z0-9!#$&^_.+-]*$"
            },
            "bytes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 26214400
            },
            "sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "sourceItemId": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          },
          "required": [
            "name",
            "mediaType",
            "bytes",
            "sha256"
          ],
          "additionalProperties": false
        }
      }
    }
  },
  "responses": {
    "201": {
      "description": "Successful response.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "upload": {
                "$ref": "#/components/schemas/FileTransfer"
              }
            },
            "required": [
              "id",
              "upload"
            ]
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "default": {
      "$ref": "#/components/responses/ApiError"
    }
  }
}
```

[Full OpenAPI contract](/openapi.json)
