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

# Quickstart

> Get up and running with the Sigmic AI API in minutes

# Quickstart

This guide walks you through making your first API request and handling the response.

## Prerequisites

* An Sigmic AI account
* An API key (create one in Settings > Developer)

## Step 1: Create Your First Task

The simplest way to test the API is with cURL:

```bash theme={null}
# Create a task (returns JSON immediately)
curl -s -X POST https://api.sigmic.ai/api/v1/tasks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "message=What is 2+2?"
```

You'll get a JSON response with the task ID:

```json theme={null}
{
  "success": true,
  "data": {
    "id": "c37c1d78-4d23-4e53-949a-ddd775f25e01",
    "status": "pending"
  }
}
```

## Step 2: Stream the Execution

Connect to the stream endpoint to watch the task execute in real-time:

```bash theme={null}
curl -N https://api.sigmic.ai/api/v1/tasks/YOUR_TASK_ID/stream \
  -H "Authorization: Bearer YOUR_API_KEY"
```

You'll see Server-Sent Events streaming back:

```
event: history_message
data: {"id":"msg-1","role":"user","content":"What is 2+2?","createdAt":"2026-01-26T15:50:54.870Z"}

event: history_done
data: {"messageCount":1,"isStreaming":true}

event: content
data: {"text":"2+2 equals 4.","isPartial":false}

event: done
data: {"finalResponse":"2+2 equals 4."}
```

## Step 3: Send a Follow-up

Send a follow-up message, then reconnect to the stream:

```bash theme={null}
# Send the follow-up (returns JSON immediately)
curl -s -X POST https://api.sigmic.ai/api/v1/tasks/YOUR_TASK_ID/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "Now multiply that by 10"}'

# Stream the response (includes full history)
curl -N https://api.sigmic.ai/api/v1/tasks/YOUR_TASK_ID/stream \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## Complete Working Example

Here's a minimal working example in Node.js:

```javascript theme={null}
const API_KEY = 'sigmic_your_key_here';
const BASE_URL = 'https://api.sigmic.ai';

async function runTask(message) {
  // 1. Create the task
  const formData = new FormData();
  formData.append('message', message);

  const createResponse = await fetch(`${BASE_URL}/api/v1/tasks`, {
    method: 'POST',
    headers: { 'Authorization': `Bearer ${API_KEY}` },
    body: formData
  });

  const { data: { id: taskId } } = await createResponse.json();
  console.log('Task ID:', taskId);

  // 2. Stream the execution
  const streamResponse = await fetch(`${BASE_URL}/api/v1/tasks/${taskId}/stream`, {
    headers: { 'Authorization': `Bearer ${API_KEY}` }
  });

  const reader = streamResponse.body.getReader();
  const decoder = new TextDecoder();
  let buffer = '';
  let finalResponse = '';

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;

    buffer += decoder.decode(value, { stream: true });
    const events = buffer.split('\n\n');
    buffer = events.pop() || '';

    for (const eventStr of events) {
      if (!eventStr.trim() || eventStr.startsWith(':')) continue;

      const lines = eventStr.split('\n');
      const eventType = lines[0]?.replace('event: ', '');
      const dataLine = lines[1]?.replace('data: ', '');
      if (!dataLine) continue;

      const data = JSON.parse(dataLine);

      if (eventType === 'history_done') {
        console.log(`Loaded ${data.messageCount} history messages`);
      }
      if (eventType === 'content') {
        process.stdout.write(data.text);
      }
      if (eventType === 'done') {
        finalResponse = data.finalResponse;
        console.log('\n');
      }
    }
  }

  return { taskId, finalResponse };
}

// Run it
const { taskId, finalResponse } = await runTask('Explain what an API is in one sentence');
console.log('Final response:', finalResponse);
```

## What's Next?

<CardGroup cols={2}>
  <Card title="Upload Files" icon="upload" href="/tasks/create#with-file-upload">
    Learn how to include files in your tasks
  </Card>

  <Card title="Stream Events" icon="wave-pulse" href="/tasks/stream">
    Understand the unified SSE stream endpoint
  </Card>

  <Card title="Artifacts" icon="file-export" href="/tasks/artifacts">
    List and download files generated by the agent
  </Card>

  <Card title="Tool Approval" icon="shield-check" href="/tasks/approve">
    Control which tools the agent can execute
  </Card>
</CardGroup>
