> For the complete documentation index, see [llms.txt](https://diffio.ai/llms.txt). This page is also available as HTML at https://diffio.ai/docs/api-reference/create-project/.

# Create a project

Creates a project for one audio or video recording and returns pre-built multipart upload instructions (`upload.requests`). Pass `generation` to queue the first restore immediately so it starts automatically as soon as the upload is ready.

POST `https://api.diffio.ai/v2/projects`

- Key scope: `projects:write`
- Auth header: `Authorization: Bearer <apiKey>`
- Body: JSON

**The HTTP upload sequence, call by call**

1. POST `/projects` id and upload
2. POST `upload.requests.start.url` uploadId
3. PUT `upload.requests.part.url (one per part)` etag per part
4. POST `upload.requests.complete.url` sizeBytes, etag
5. POST `/projects/{project_id}/upload/complete` optional; status preparing or ready

Every edge call: `Authorization: Bearer {upload_token}` Parts ≤ 32 MiB (`part_size_bytes`, numbered from 1)

## Request

Send a JSON object naming the recording (`file_name`) and optional file size, MIME type, metadata, or initial `generation`.

### Headers

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `Diffio-End-User` | string | No | Optional end-user identifier (up to 128 characters). Assigns the new project to `end_user` and scopes `Idempotency-Key` to that end user. |
| `Idempotency-Key` | string | No | Optional key (up to 255 characters) for safe retries. Repeating the same request returns the original project; changing any body field returns `409` (`idempotency_key_conflict`). |

### Body fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file_name` | string | Yes | Recording filename with a supported audio or video extension. |
| `content_type` | string | No | Recording MIME type (for example `audio/mpeg` or `video/mp4`); defaults to `application/octet-stream` when omitted. |
| `size_bytes` | integer | No | File size in bytes when known, from `0` up to `2147483648` (2 GB). |
| `metadata` | object | No | Optional string-to-string map saved on the project (up to 50 keys; each key up to 40 characters, each value up to 500 characters). |
| `generation` | object | No | Optional initial restore to queue immediately (`latest_generation`); requires `generations:write` scope in addition to `projects:write`. [Fields below](#fields-generation) |

**`generation` fields**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `generation.model` | string | Yes | Model ID from `GET /models`, such as `diffio-flash` or `diffio-pro`. |
| `generation.sampling` | object | No | Optional advanced sampling overrides object. |
| `generation.label` | string | No | Optional caller-defined name for the generation (up to 120 characters). |

## Example request

**Python**

```python
import os
from diffio import DiffioClient

key = os.environ["DIFFIO_API_KEY"]
client = DiffioClient(api_key=key)

project = client.projects.create(
    file_name="interview.mp3",
    content_type="audio/mpeg",
    size_bytes=510957,
    metadata={"order_id": "1042"},
    end_user="customer-mwe8tm1g",
    idempotency_key="v2docs-a-mwe8tm1g",
)
```

**Node.js**

```javascript
import { DiffioClient } from "diffio"

const client = new DiffioClient({
  apiKey: process.env.DIFFIO_API_KEY,
})

const project =
  await client.projects.create(
    {
      file_name: "interview.mp3",
      content_type: "audio/mpeg",
      size_bytes: 510957,
      metadata: { "order_id": "1042" },
    },
    {
      endUser: "customer-mwe8tm1g",
      idempotencyKey: "v2docs-a-mwe8tm1g",
    },
  )
```

**cURL**

```bash
curl -X POST "https://api.diffio.ai/v2/projects" \
  -H "Authorization: Bearer $DIFFIO_API_KEY" \
  -H "Diffio-End-User: customer-mwe8tm1g" \
  -H "Idempotency-Key: v2docs-a-mwe8tm1g" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "interview.mp3",
    "content_type": "audio/mpeg",
    "size_bytes": 510957,
    "metadata": {
      "order_id": "1042"
    }
  }'
```

**JSON: JSON body**

```json
{
  "file_name": "interview.mp3",
  "content_type": "audio/mpeg",
  "size_bytes": 510957,
  "metadata": {
    "order_id": "1042"
  }
}
```

## Response

Returns the new `project` (`status: "awaiting_upload"`) with signed multipart `upload` instructions valid for 24 hours.

Success: `201`

### Response fields

| Field | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | string | Always | Unique project identifier (UUID). |
| `object` | string | Always | Resource type, always `"project"`. |
| `status` | string | Always | Upload and preparation state: `awaiting_upload` until bytes arrive, `preparing` while media is probed, `ready` when ready to restore, or `failed`. |
| `latest_generation` | object \| null | Always | Newest `Generation` object on this project, or `null` when no generation exists yet. |
| `upload` | object \| null | Always | Multipart upload instructions for sending the file to the media edge, or `null` on an idempotent replay after the upload has arrived. [Fields below](#fields-upload) |

**`upload` fields**

| Field | Type | Present | Description |
| --- | --- | --- | --- |
| `upload.upload_session_id` | string | Always | Upload session identifier (`api-{project_id}`). |
| `upload.edge_base_url` | string | Always | Origin URL of the media upload edge (`https://media.diffio.io`). |
| `upload.upload_token` | string | Always | Signed bearer token sent as `Authorization: Bearer <token>` on every upload edge request. |
| `upload.part_size_bytes` | integer | Always | Required byte length for every upload part except the last (`33554432`, 32 MiB). |
| `upload.max_bytes` | integer | Always | Maximum total upload size in bytes (`2147483648`, 2 GB). |
| `upload.expires_at` | string | Always | ISO 8601 UTC timestamp when `upload_token` expires (24 hours after minting); renew via `POST /projects/{project_id}/upload`. |
| `upload.requests` | object | Always | Pre-built HTTP request descriptors for the multipart upload (`start`, `part`, `complete`, `abort`). |
| `upload.requests.start` | object | Always | Descriptor (`method`, `url`, `headers`, `body`, `returns`, `description`) called once first to obtain `uploadId`. |
| `upload.requests.part` | object | Always | Descriptor called once per part (numbered from `1`) with raw bytes as the `PUT` body; save each returned `etag`. |
| `upload.requests.complete` | object | Always | Descriptor called once after all parts finish, sending `uploadId` and the ordered `parts` array (`partNumber`, `etag`). |
| `upload.requests.abort` | object | Always | Optional descriptor to discard uploaded parts for an unfinished `uploadId`. |

**Other response fields**

| Field | Type | Present | Description |
| --- | --- | --- | --- |
| `file_name` | string \| null | Always | Recording filename as sent at creation, or `null`. |
| `content_type` | string \| null | Always | MIME type sent at creation (`application/octet-stream` when none was sent), or `null`. |
| `size_bytes` | integer \| null | Always | File size in bytes: the uploaded byte count once the upload arrives, before that the `size_bytes` sent at creation; `null` when unknown. |
| `duration_seconds` | number \| null | Always | Recording duration in seconds once `status` is `ready`, or `null` while awaiting upload or preparing. |
| `has_video` | boolean | Always | True when the recording has video: inferred from `content_type` or the file name until the upload is probed, then from the file itself. |
| `end_user` | string \| null | Always | End-user identifier from the `Diffio-End-User` header at creation, or `null` for account-level projects. |
| `metadata` | object | Always | Key-value string map saved with the project (`{}` when none was supplied). |
| `generation_count` | integer | Always | Total number of generations created for this project. |
| `video_preview_status` | string \| null | Always | State of a video project's picture-only HLS stream (`video_hls`): `preparing`, `ready`, or `failed`; `null` for audio projects. |
| `share_id` | string \| null | Always | Public 17-character share identifier while a share is published, or `null` when unshared. |
| `created_at` | string \| null | Always | ISO 8601 UTC timestamp when the project was created, or `null`. |
| `updated_at` | string \| null | Always | ISO 8601 UTC timestamp when the project last changed, or `null`. |
| `error` | object \| null | Always | Failure details when `status` is `failed`, or `null` otherwise. |
| `error.code` | string | Always | Stable `snake_case` project failure code (`media_processing_failed` or `project_failed`). |
| `error.message` | string | Always | Human-readable explanation of why the upload could not be prepared. |

## Example response (201)

**Response, key fields: Response: key fields**

```json
{
  "id": "62f62565-049f-5e7e-bbd2-9de0cf7ddbfe",
  "object": "project",
  "status": "awaiting_upload",
  "latest_generation": null,
  "upload": {
    "upload_token": "v1.REDACTED",
    "part_size_bytes": 33554432,
    "expires_at": "2026-11-14T00:33:21.812909Z",
    "requests": {
      "start": {
        "method": "POST",
        "url": "https://media.diffio.io/v1/uploads/start",
        "headers": {
          "Authorization": "Bearer v1.REDACTED"
        },
        "body": null,
        "returns": [
          "uploadId",
          "partSizeBytes",
          "maxBytes"
        ],
        "description": "Once, first. Keep uploadId for the other requests."
      }
    }
  }
}
```

**Full response: Successful response**

```json
{
  "id": "62f62565-049f-5e7e-bbd2-9de0cf7ddbfe",
  "object": "project",
  "status": "awaiting_upload",
  "file_name": "interview.mp3",
  "content_type": "audio/mpeg",
  "size_bytes": 510957,
  "duration_seconds": null,
  "has_video": false,
  "end_user": "customer-mwe8tm1g",
  "metadata": {
    "order_id": "1042"
  },
  "generation_count": 0,
  "video_preview_status": null,
  "latest_generation": null,
  "share_id": null,
  "created_at": "2026-11-13T00:33:21.812909Z",
  "updated_at": "2026-11-13T00:33:21.812909Z",
  "error": null,
  "upload": {
    "upload_session_id": "api-62f62565-049f-5e7e-bbd2-9de0cf7ddbfe",
    "edge_base_url": "https://media.diffio.io",
    "upload_token": "v1.REDACTED",
    "part_size_bytes": 33554432,
    "max_bytes": 2147483648,
    "expires_at": "2026-11-14T00:33:21.812909Z",
    "requests": {
      "start": {
        "method": "POST",
        "url": "https://media.diffio.io/v1/uploads/start",
        "headers": {
          "Authorization": "Bearer v1.REDACTED"
        },
        "body": null,
        "returns": [
          "uploadId",
          "partSizeBytes",
          "maxBytes"
        ],
        "description": "Once, first. Keep uploadId for the other requests."
      },
      "part": {
        "method": "PUT",
        "url": "https://media.diffio.io/v1/uploads/parts/{part_number}?uploadId={upload_id}",
        "headers": {
          "Authorization": "Bearer v1.REDACTED",
          "Content-Length": "{part_length}"
        },
        "body": null,
        "returns": [
          "partNumber",
          "etag"
        ],
        "description": "Once per part, numbered from 1; the body is the part's raw bytes. Every part but the last is exactly part_size_bytes. Keep each etag."
      },
      "complete": {
        "method": "POST",
        "url": "https://media.diffio.io/v1/uploads/complete",
        "headers": {
          "Authorization": "Bearer v1.REDACTED",
          "Content-Type": "application/json"
        },
        "body": {
          "uploadId": "{upload_id}",
          "parts": [
            {
              "partNumber": "{part_number}",
              "etag": "{etag}"
            }
          ]
        },
        "returns": [
          "sizeBytes",
          "etag"
        ],
        "description": "Once, after every part, listing every part. Repeating it is safe."
      },
      "abort": {
        "method": "POST",
        "url": "https://media.diffio.io/v1/uploads/abort",
        "headers": {
          "Authorization": "Bearer v1.REDACTED",
          "Content-Type": "application/json"
        },
        "body": {
          "uploadId": "{upload_id}"
        },
        "returns": [],
        "description": "Optional: drop an unfinished upload's parts."
      }
    }
  }
}
```

## Return codes

- `201` Project created with multipart `upload` instructions (and queued `latest_generation` when `generation` was sent).
- `400`
  - Malformed JSON: [`invalid_json`](https://diffio.ai/docs/api-reference/errors/#invalid_json)
  - Missing `file_name`: [`missing_field`](https://diffio.ai/docs/api-reference/errors/#missing_field)
  - Invalid body field: [`invalid_field`](https://diffio.ai/docs/api-reference/errors/#invalid_field)
  - Oversized header: [`invalid_header`](https://diffio.ai/docs/api-reference/errors/#invalid_header)
  - Unknown `generation.model`: [`unknown_model`](https://diffio.ai/docs/api-reference/errors/#unknown_model)
- `402` When `generation` is included and the account cannot pay for the first restore (checked at the 60-second minimum until the upload is probed); see the error codes below. [`insufficient_credit`](https://diffio.ai/docs/api-reference/errors/#insufficient_credit) [`needs_payment_method`](https://diffio.ai/docs/api-reference/errors/#needs_payment_method) [`payment_failed`](https://diffio.ai/docs/api-reference/errors/#payment_failed) [`usage_limit_reached`](https://diffio.ai/docs/api-reference/errors/#usage_limit_reached)
- `403` Key is inactive or lacks `projects:write`, or `generations:write` when `generation` is included. [`permission_denied`](https://diffio.ai/docs/api-reference/errors/#permission_denied)
- `409` Reused `Idempotency-Key` with different request fields. [`idempotency_key_conflict`](https://diffio.ai/docs/api-reference/errors/#idempotency_key_conflict)
- `413` `size_bytes` exceeds the 2 GB (`2,147,483,648` bytes) upload limit. [`upload_too_large`](https://diffio.ai/docs/api-reference/errors/#upload_too_large)
- `415` File extension or `content_type` is not a supported audio or video format. [`unsupported_media_type`](https://diffio.ai/docs/api-reference/errors/#unsupported_media_type)
- `500` Initial `generation` could not be started and nothing was charged, or server error. [`generation_start_failed`](https://diffio.ai/docs/api-reference/errors/#generation_start_failed) [`internal_error`](https://diffio.ai/docs/api-reference/errors/#internal_error)
- **`401` `405` Same on every endpoint**

  - `401` Missing API key (code missing_api_key), or invalid API key (code invalid_api_key).
  - `405` HTTP method not supported on this path; check the Allow header (code method_not_allowed).

### Error codes

| Status | Code | Meaning | Also returned |
| --- | --- | --- | --- |
| `402` | [`insufficient_credit`](https://diffio.ai/docs/api-reference/errors/#insufficient_credit) | Your API credit is used up, or cannot cover this file. | `estimated_cost_cents` `remaining_credit_cents` |
| `402` | [`needs_payment_method`](https://diffio.ai/docs/api-reference/errors/#needs_payment_method) | Card billing accounts: no payment method, and the credit is used up or cannot cover this file. | `estimated_cost_cents` `remaining_credit_cents` (when the credit was read) |
| `402` | [`payment_failed`](https://diffio.ai/docs/api-reference/errors/#payment_failed) | A payment for API usage failed, or the last invoice of ended card billing is unpaid. | `details` omitted |
| `402` | [`usage_limit_reached`](https://diffio.ai/docs/api-reference/errors/#usage_limit_reached) | Unbilled usage reached $100; it is being charged now. | `details` omitted |
| `409` | [`idempotency_key_conflict`](https://diffio.ai/docs/api-reference/errors/#idempotency_key_conflict) | Idempotency-Key was already used with different request fields. | `details` omitted |

### Example error response

**Error response**

```json
{
  "error": {
    "code": "insufficient_credit",
    "message": "This file needs about $1.25 of API credit and your balance is $0.40. Add credit in the developer dashboard to continue.",
    "request_id": "f064e4099097414da3fb5b37684ab1bb",
    "details": {
      "estimated_cost_cents": 125,
      "remaining_credit_cents": 40
    }
  }
}
```

## Notes

- Upload the recording by executing `upload.requests.start`, `upload.requests.part` (32 MiB parts except the last), and `upload.requests.complete`, or call `client.projects.upload(...)` in the Python and Node.js SDKs.
- Files can be up to 2 GB (`2,147,483,648` bytes) with no media length limit.
- After `upload.requests.complete` succeeds, the upload edge reports completion automatically within about 30 seconds; call [Complete a project's upload](https://diffio.ai/docs/api-reference/complete-project-upload/) to make readiness immediate.

## Related pages

- Previous: [List models](https://diffio.ai/docs/api-reference/list-models/): List every hosted model, tier alias, and retired model name with hourly list pricing.
- Next: [List projects](https://diffio.ai/docs/api-reference/list-projects/): List projects on the account newest first with cursor pagination.

- [Full API guide](https://diffio.ai/docs/developers/full-api-guide/): Every topic, limit and concept in one index.
- [Diffio API overview](https://diffio.ai/api-overview/): The cloud batch workflow and SDKs on one page.
