> For the complete documentation index, see [llms.txt](https://lamatic.ai/llms.txt).

# API Overview

Lamatic exposes a **GraphQL API** as the primary way to run Flows from your app, CLI, or backend. This page explains why we use GraphQL, how to authenticate, and where to find the full reference.

## Why GraphQL?

Most developer tools use REST (`POST /api/v1/flows/{id}/execute`). Lamatic uses **GraphQL** because:

- **Dynamic schemas**: The shape of inputs and outputs depends on how your Flow is configured. GraphQL lets you request exactly the fields you need and matches the response to your Flow's schema.
- **Single endpoint**: One URL per project; the operation and variables are in the request body.
- **Strong typing**: Queries and responses align with your Flow's input/output definitions.

If you're used to REST, you can think of "execute a Flow" as a single mutation: `executeWorkflow(workflowId, payload)`.

## Quick orientation

| You want to…              | Go to |
|--------------------------|--------|
| Get an API key           | [API Keys](/docs/api-integration/api-key) |
| Call a Flow from code    | [Integration Guide](/docs/sdk/integration-guide) |
| See GraphQL operations   | [GraphQL](/docs/interface/graphql) |
| Use the SDK (JS/React/Go) | [SDK](/docs/sdk) |
| Webhooks / Widgets       | [Webhooks](/docs/interface/webhooks), [Widgets](/docs/interface/widgets/chat) |

## Authentication

All API requests use **Bearer token** authentication with an API key:

- **Header:** `Authorization: Bearer <YOUR_API_KEY>`
- **Project scope:** `x-project-id: <PROJECT_ID>`

Create and copy your API key from **Studio → Settings → API Keys**. Never commit the key; use environment variables or a secrets manager.

## Minimal example

**Prerequisites:** `<YOUR_API_KEY>`, `<PROJECT_ID>`, `<FLOW_ID>`, and `<PROJECT_ENDPOINT>` from Studio (project settings and the Flow's Connect/API panel).

```bash
curl -X POST "<PROJECT_ENDPOINT>" \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -H "x-project-id: <PROJECT_ID>" \
  -d '{
    "query": "query ExecuteWorkflow($workflowId: String!, $payload: JSON) { executeWorkflow(workflowId: $workflowId, payload: $payload) { status result } }",
    "variables": {
      "workflowId": "<FLOW_ID>",
      "payload": { "question": "Hello" }
    }
  }'
```

The response includes `status` (e.g. `success`) and `result` (your Flow's output as configured in the GraphQL Response node).

## Next steps

- [Integration Guide](/docs/sdk/integration-guide): Step-by-step setup and examples in JavaScript, Python, and cURL.
- [GraphQL](/docs/interface/graphql): Full request/response shapes, async flows, and schema.
- [Error Codes](/docs/error-reference): Diagnose failed requests.
- [Limits & Quotas](/docs/limits): Rate limits and payload size.
