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

# Create an attachment upload

> Reserve an attachment upload: the response names where to PUT the file.
The upload id then goes in the attestation as `attachment_upload_id`.
Upload the file first, then attest.



## OpenAPI

````yaml https://app.kosli.com/api/v2/openapi.json post /attestations/{org}/uploads
openapi: 3.1.0
info:
  title: Kosli API
  summary: The API for communicating with Kosli
  description: >

    # Authentication 


    When making requests against Kosli API, you can authenticate your requests
    using a bearer token. 

    Set the bearer token in the request Authorization header to a valid API
    key. 

    API Keys can be personal or for service accounts. Check the [service
    accounts
    documentation](https://docs.kosli.com/getting_started/service-accounts/) for
    details. 


    ## Curl example


    ```shell

    curl -H "Authorization: Bearer <<your-api-key>>"
    https://app.kosli.com/api/v2/environments/<<your-org-name>>

    ```
  version: '2.0'
servers:
  - url: https://app.kosli.com/api/v2
    description: EU
  - url: https://app.us.kosli.com/api/v2
    description: US
security:
  - HTTPBearer: []
paths:
  /attestations/{org}/uploads:
    post:
      tags:
        - Attestation
      summary: Create an attachment upload
      description: |-
        Reserve an attachment upload: the response names where to PUT the file.
        The upload id then goes in the attestation as `attachment_upload_id`.
        Upload the file first, then attest.
      operationId: create_attestation_upload
      parameters:
        - name: org
          in: path
          required: true
          schema:
            type: string
            title: Org
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UploadPostInput'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadResponse'
        '400':
          description: File size over the org's limit
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/fastapi_app__errors__BadRequestResponse___locals___BadRequestResponseModel__1
        '404':
          description: Direct uploads not available
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/fastapi_app__errors__NotFoundResponse___locals___NotFoundResponseModel__4
      security:
        - HTTPBearer: []
        - HTTPBasic: []
components:
  schemas:
    UploadPostInput:
      properties:
        filename:
          type: string
          maxLength: 255
          minLength: 1
          title: Filename
          description: The name the attachment is stored and downloaded under
        size_bytes:
          type: integer
          maximum: 5368709120
          minimum: 1
          title: Size Bytes
          description: The size of the file, checked against the org's limit
        sha256:
          type: string
          pattern: ^[a-f0-9]{64}$
          title: Sha256
          description: Hex SHA-256 of the file; S3 refuses the upload if the body differs
      additionalProperties: false
      type: object
      required:
        - filename
        - size_bytes
        - sha256
      title: UploadPostInput
    UploadResponse:
      properties:
        upload_id:
          type: string
          title: Upload Id
          description: Names this upload in the attestation that attaches it
        url:
          type: string
          title: Url
          description: Where to PUT the file, valid until upload_url_expires_at
        method:
          type: string
          const: PUT
          title: Method
        headers:
          additionalProperties:
            type: string
          type: object
          title: Headers
          description: Headers the PUT must carry exactly as given; they are signed
        upload_url_expires_at:
          type: number
          title: Upload Url Expires At
          description: Epoch seconds after which the PUT is refused; mint again to retry
        upload_id_expires_at:
          type: number
          title: Upload Id Expires At
          description: >-
            Epoch seconds after which the attest call refuses the upload id and
            the uploaded file is discarded; mint and upload again to recover
        max_size_bytes:
          type: integer
          title: Max Size Bytes
          description: The org's limit for a single upload
      type: object
      required:
        - upload_id
        - url
        - method
        - headers
        - upload_url_expires_at
        - upload_id_expires_at
        - max_size_bytes
      title: UploadResponse
    fastapi_app__errors__BadRequestResponse___locals___BadRequestResponseModel__1:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        errors:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Errors
          description: Validation errors by field
      type: object
      required:
        - message
      title: BadRequestResponseModel
      examples:
        - message: Input payload validation failed
    fastapi_app__errors__NotFoundResponse___locals___NotFoundResponseModel__4:
      properties:
        message:
          type: string
          title: Message
          description: Error message
        errors:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Errors
          description: Validation errors by field
      type: object
      required:
        - message
      title: NotFoundResponseModel
      description: Resource Not Found
      examples:
        - message: Resource Not Found
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

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