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

# GraphQL API overview

> Send authenticated GraphQL requests and follow a generation from submission to downloadable media.

The APOB GraphQL API uses a single HTTP endpoint, `POST /graphql`. Choose a query
to read existing resources or a mutation to create or change them. This reference
covers account access, model and element discovery, image and video generation,
speech, avatars, and generation results.

Use the GraphQL URL supplied for your APOB integration as `APOB_GRAPHQL_URL`.
The examples use synthetic resource IDs; replace them with resources accessible
to your account. Required fields and defaults describe the API contract, while
account access, available credits, and supported setting combinations are checked
when an operation runs.

## Make your first request

Obtain an APOB API key through your signed-in APOB integration. Send the complete
key in `Authorization: Bearer <APOB_API_KEY>` on every authenticated request.
See [authentication](/api-reference/authentication) for key management and the
separate Firebase login flow.

```bash cURL theme={null}
curl --request POST "$APOB_GRAPHQL_URL" \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $APOB_API_KEY" \
  --data '{"operationName":"CurrentAccount","query":"query CurrentAccount { getUserByPrivateId { id alias creditBalances { category amount } } }","variables":{}}'
```

## Request and response format

| Request property | Type | Meaning |
| - | - | - |
| `query` | `String` | GraphQL operation and selected response fields. Required. |
| `variables` | Object | Values for the operation's variables. |
| `operationName` | `String` | Name of the operation to execute; required when the document contains multiple operations. |

The response contains `data`, `errors`, or both. Read the GraphQL `errors` array
even when HTTP returns 200. A mutation can create a resource before a selected
response field fails, so an error does not always prove that submission failed.

## Call from JavaScript

This helper accepts an already obtained APOB API key. It performs one HTTP
request and reports HTTP or GraphQL errors without automatically retrying.

```javascript JavaScript theme={null}
async function apobGraphql(url, apiKey, query, variables, operationName) {
  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${apiKey}`,
    },
    body: JSON.stringify({ query, variables, operationName }),
  });
  const result = await response.json();
  if (!response.ok || result.errors?.length) {
    const error = new Error("APOB GraphQL request failed");
    error.status = response.status;
    error.errors = result.errors;
    error.data = result.data;
    throw error;
  }
  return result.data;
}
```

## Complete a generation

<Steps>
  <Step title="Discover inputs">
    Read your [account](/api-reference/account), choose an accessible ready model,
    and select [models and elements](/api-reference/models-and-elements).
  </Step>

  <Step title="Submit once">
    Use the image, video, or speech mutation and retain the returned content ID
    and task ID. Generation mutations can consume credits.
  </Step>

  <Step title="Poll the existing content">
    Read the [task and results](/api-reference/tasks-and-results) until the task
    finishes. Success requires both `status: finished` and `finishCode: 0`.
  </Step>

  <Step title="Download outputs">
    Select the returned media IDs and request download URLs. Refresh an expired
    URL by reading the same result again.
  </Step>
</Steps>

<Warning>
  Do not automatically resubmit a generation after a timeout, connection loss,
  or partial GraphQL response. Reconcile the existing content or account history
  first; a second mutation can start and charge for a separate generation.
</Warning>

For authentication and operation failures, see [errors](/api-reference/errors).


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