Skip to content

Upload a container ​

This guide explains how to upload audio and video files to Aive using the public GraphQL API.

Large files are uploaded using a multipart upload workflow. This approach improves reliability by allowing failed uploads to resume without restarting the entire upload. If your file is already hosted somewhere reachable over HTTP, you can skip the multipart workflow entirely — see Alternative: upload from a URL.

The multipart upload process consists of four steps:

text
Create Upload
      ↓
Upload Parts
      ↓
Finalize Upload
      ↓
Create Container (starts extraction)

A container is considered ready to use once the extraction process has completed successfully. Extraction is asynchronous — see Event handling for how to be notified when it completes.

Step 1 - Create an upload ​

The first step is to request a multipart upload.

Specify the number of parts you want to split your file into. The API returns an upload key, an upload ID, and one signed upload URL for each part.

CreateUpload mutation ​

graphql
mutation CreateUpload($input: CreateUploadInput!) {
  createUpload(input: $input) {
    ... on CreateUploadResult {
      uploadId
      key
      parts {
        partNumber
        signedUrl
      }
    }
    ... on CreateUploadError {
      code
      message
    }
  }
}

CreateUpload variables ​

json
{
  "input": {
    "parts": 10
  }
}

CreateUpload response ​

json
{
  "data": {
    "createUpload": {
      "uploadId": "generated-upload-id",
      "key": "generated-upload-key",
      "parts": [
        {
          "partNumber": 1,
          "signedUrl": "https://..."
        }
      ]
    }
  }
}

Notes ​

  • The signed URLs are valid for 8 hours.
  • We recommend splitting files into 50 MB chunks.
  • If an upload is interrupted, only the missing parts need to be uploaded again.

Step 2 - Upload file parts ​

Upload each file part directly to the provided signed URL.

Each part must be uploaded using an HTTP PUT request, with the raw bytes of the part as the request body. Part N goes to the signed URL whose partNumber is N, so split the file in order. For example, to split a file into 50 MB parts named part-aa, part-ab, and so on:

bash
split -b 50m video.mp4 part-

Then upload each part to its signed URL:

bash
curl --request PUT \
  --upload-file part-aa \
  "<signed_url_for_part_1>"

A part is uploaded once the request returns HTTP 200. All parts can be uploaded in parallel to reduce upload time.

Step 3 - Finalize the upload ​

Once every part has been uploaded successfully, finalize the multipart upload.

This operation assembles all uploaded parts into a single file stored by Aive.

FinalizeUpload mutation ​

graphql
mutation FinalizeUpload($input: FinalizeUploadInput!) {
  finalizeUpload(input: $input) {
    ... on FinalizeUploadResult {
      success
    }
    ... on FinalizeUploadError {
      code
      message
    }
  }
}

FinalizeUpload variables ​

json
{
  "input": {
    "key": "<upload_key>",
    "uploadId": "<upload_id>",
    "parts": [
      {
        "partNumber": 1,
        "eTag": ""
      }
    ]
  }
}

Note

The eTag field is currently ignored — pass an empty string, it does not need to reflect a real value.

Step 4 - Create the container and start extraction ​

After the upload has been finalized, create the container from it. This starts the extraction process, which retrieves the metadata required by Aive to use the uploaded media.

To create the container, you must specify the destination folder using the folderId parameter.

At the moment, the easiest way to retrieve a folder ID is from the Aive web application:

  1. Open the destination folder in Aive.
  2. Copy the folder identifier from the URL.

For example, if the URL is:

text
https://app.aive.com/w/workspace/<workspace_id>/folders/<folder_id>

then:

  • <workspace_id> is the workspace identifier.
  • <folder_id> is the unique identifier of the destination folder.

You can also list the folders at the root of your workspace through the API:

graphql
query Folders($workspaceId: ID!) {
  workspace(id: $workspaceId) {
    files(input: { recursive: false, types: [folder], size: 50, cursor: 0, sortBy: name, sortDirection: asc }) {
      items {
        ... on Folder {
          id
          name
        }
      }
    }
  }
}

To list the subfolders of a folder, query folder(id: <folder_id>) with the same files field, without the recursive argument.

UploadContainer mutation ​

graphql
mutation UploadContainer($input: UploadContainerInput!) {
  uploadContainer(input: $input) {
    ... on UploadContainerResult {
      containerId
    }
    ... on UploadContainerError {
      code
      message
    }
  }
}

UploadContainer variables ​

json
{
  "input": {
    "folderId": "<folder_id>",
    "name": "<container_name>",
    "s3": {
      "key": "<upload_key>"
    }
  }
}

The s3 input refers to a file uploaded with the multipart workflow above, identified by its upload key, whatever storage the signed URLs point to.

UploadContainer response ​

json
{
  "data": {
    "uploadContainer": {
      "containerId": "<container_id>"
    }
  }
}

Other input fields ​

FieldDescription
dubbedFromIdThe ID of the container this one was dubbed from, if applicable.
laneThe processing lane used for the extraction. Administrator only — external API clients should not provide this field.

Important

This mutation is not idempotent. Do not call it multiple times for the same upload unless instructed to retry after a failure. See Error handling for details.

Step 5 - Wait for the container extraction event ​

Container extraction is an asynchronous operation. Instead of polling, subscribe to the extractionCompleted webhook event to be notified as soon as extraction completes — see Event handling for the payload shape and how to poll instead if you can't use webhooks.

A container can only be used once its extraction status is succeeded.

Alternative: upload from a URL ​

If your file is already hosted at a reachable HTTP URL, you can skip the multipart upload workflow (steps 1-3) entirely and call uploadContainer directly with the http input instead of s3. Aive fetches the file itself.

graphql
mutation UploadContainer($input: UploadContainerInput!) {
  uploadContainer(input: $input) {
    ... on UploadContainerResult {
      containerId
    }
    ... on UploadContainerError {
      code
      message
    }
  }
}
json
{
  "input": {
    "folderId": "<folder_id>",
    "name": "<container_name>",
    "http": {
      "url": "https://example.com/path/to/file.mp4"
    }
  }
}

The rest of the workflow (extraction, extractionCompleted webhook event) is identical to the multipart upload path.

Retry after a failure ​

If the extraction fails:

  1. Verify that every file part was uploaded successfully.
  2. Verify that the multipart upload was finalized successfully.
  3. Call the uploadContainer mutation again to restart the extraction.

Best practices ​

  • Split large files into 50 MB chunks.
  • Upload parts in parallel whenever possible.
  • Re-upload only the missing parts if an upload is interrupted.
  • Finalize the upload only after every part has been uploaded successfully.
  • Subscribe to the extractionCompleted webhook event and wait for it to report succeeded before using the container in any subsequent operation, such as media analysis.
  • Signed upload URLs remain valid for 8 hours.
  • There is currently no documented limit on the number of upload parts (the uploadMaxSizeExceeded error applies to the assembled file size).

See Error handling for the full list of error codes returned by the upload mutations.