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

# Commit a Drive Upload

> Validate an uploaded file and make it available in Drive.

After [starting an upload](https://docs.transparencyhubnetwork.ai/api-reference/drive/upload-session.md) and putting the bytes at its temporary URL, commit the session to create the Drive file.

**Required scope:** `drive:write`

> [!NOTE]
>
> This endpoint requires the Drive document creation API to be deployed to the selected environment, with Drive enabled.

Use the original API key. The session must belong to the key owner and the resolved chapter. Association-wide keys must specify the original `chapter_id` again.

The API rechecks current folder permissions, the file's exact size, its signature and available storage quota. On success, it creates the file with inherited permissions and records the upload in the chapter's activity log.

```json Request theme={null}
{
  "upload_session_id": 123
}
```

```json 201 theme={null}
{
  "status": "success",
  "data": {
    "id": 502,
    "parent_id": 22,
    "is_root": false,
    "item_type": "file",
    "name": "Annual report.pdf",
    "file_size": 12345,
    "content_type": "application/pdf",
    "content_version": 0,
    "createdby": 7,
    "createddate": "2026-10-24T10:05:00Z",
    "lastmodifieddate": null
  }
}
```

The file now appears in Drive. The response includes metadata; use its `id` with [Download a Drive File](https://docs.transparencyhubnetwork.ai/api-reference/drive/download.md) to fetch it with `drive:download`.

| Status | Meaning |
| - | - |
| `400` | Missing uploaded bytes, size mismatch, invalid signature or quota exceeded |
| `403` | Missing scope, forbidden chapter or insufficient current Drive permissions |
| `404` | Session unavailable, including one owned by someone else or in another chapter |
| `409` | Session already finalized, or a file with this name already exists |
| `410` | Session expired; start a new upload |
| `503` | Drive is disabled |

A session can be committed once. After an uncertain response, check [List Drive Items](https://docs.transparencyhubnetwork.ai/api-reference/drive/items.md) before starting another upload; listing requires `drive:read`.


## OpenAPI

````yaml POST /v1/drive/files/commit
openapi: 3.0.3
info:
  title: Transparency Hub Public API
  version: 1.7.0
  description: Key-authenticated REST API for association and chapter integrations.
servers:
  - url: https://api.transparencyhubnetwork.ai/api
  - url: https://testapi.transparencyhubnetwork.ai/api
    description: Test
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /v1/drive/files/commit:
    post:
      summary: Commit a Drive file upload
      description: >-
        Requires drive:write. The session must belong to the key owner and the
        resolved chapter. Rechecks current Drive permissions, file
        size/signature and storage quota; inserts the item and upload audit
        atomically. A session can only be committed once.
      parameters:
        - $ref: '#/components/parameters/chapterId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CommitDriveUpload'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  data:
                    $ref: '#/components/schemas/DriveItem'
        '400':
          description: >-
            Invalid input, unsupported file type, invalid file signature, size
            mismatch, or quota exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            Missing drive:write scope, forbidden chapter, or insufficient Drive
            permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Parent folder or upload session not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: File name conflict or upload session already finalized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: Upload session expired
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Drive is disabled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    chapterId:
      name: chapter_id
      in: query
      schema:
        type: integer
      description: >-
        Required for association-wide keys; must match the key's chapter for
        chapter-bound keys.
  schemas:
    CommitDriveUpload:
      type: object
      required:
        - upload_session_id
      properties:
        chapter_id:
          type: integer
          minimum: 1
          description: >-
            Required for association-wide keys; otherwise the key chapter is
            used.
        upload_session_id:
          type: integer
          minimum: 1
    DriveItem:
      type: object
      properties:
        id:
          type: integer
          nullable: true
        parent_id:
          type: integer
          nullable: true
        is_root:
          type: boolean
          nullable: true
        item_type:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        file_size:
          type: integer
          nullable: true
        content_type:
          type: string
          nullable: true
        content_version:
          type: integer
          nullable: true
        createdby:
          type: integer
          nullable: true
        createddate:
          type: string
          format: date-time
          nullable: true
        lastmodifieddate:
          type: string
          format: date-time
          nullable: true
    Error:
      type: object
      required:
        - status
        - code
        - message
      properties:
        status:
          type: string
          enum:
            - error
        code:
          type: string
        message:
          type: string
        details:
          type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    BearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.