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

# Quickstart (cURL)

> Hit the Memic REST API directly from the command line — no SDK required.

If you're integrating from a language Memic doesn't have an SDK for yet, or
just want to verify the API works, you can use cURL or any HTTP client. This
walkthrough hits the same endpoints as the Python quickstart, just over raw
HTTP.

## 1. Get an API key

Grab one from the [dashboard](https://memic.ai/dashboard/api-keys) and export
it in your shell:

```bash theme={null}
export MEMIC_API_KEY="mk_live_..."
export MEMIC_BASE_URL="https://api.memic.ai/api/v1"
```

## 2. Verify authentication

```bash theme={null}
curl "$MEMIC_BASE_URL/me" \
  -H "X-API-Key: $MEMIC_API_KEY"
```

Expected response:

```json theme={null}
{
  "organization_id": "fc4dab50-480d-454f-8c62-f25248d5cd9e",
  "organization_name": "Acme Corp",
  "project_id": "49d4ff53-64df-4dd1-8714-4763954a18ac",
  "project_name": "Tech companies",
  "environment_id": "...",
  "environment_slug": "production"
}
```

If this returns your organization and project, you're authenticated.

## 3. List files in your environment

```bash theme={null}
curl "$MEMIC_BASE_URL/files" \
  -H "X-API-Key: $MEMIC_API_KEY"
```

You'll get a paginated list of files already in the environment.

## 4. Upload a file (two-step flow)

Memic uses presigned URLs for upload so large files go directly to storage.
It's a two-step process: `init` to get a presigned URL, then PUT the file to
that URL, then `confirm` to trigger processing.

### Step 1 — Initialize the upload

```bash theme={null}
curl "$MEMIC_BASE_URL/files/init" \
  -H "X-API-Key: $MEMIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "product-handbook.pdf",
    "content_type": "application/pdf",
    "size_bytes": 1048576
  }'
```

Response:

```json theme={null}
{
  "file_id": "...",
  "upload_url": "https://storage.memic.ai/...",
  "expires_at": "..."
}
```

### Step 2 — Upload the file to the presigned URL

```bash theme={null}
curl -X PUT "<upload_url from step 1>" \
  --data-binary @./product-handbook.pdf
```

### Step 3 — Confirm the upload

```bash theme={null}
curl -X POST "$MEMIC_BASE_URL/files/<file_id>/confirm" \
  -H "X-API-Key: $MEMIC_API_KEY"
```

Memic now starts processing the file (chunking, embedding, indexing).

### Step 4 — Poll for processing status

```bash theme={null}
curl "$MEMIC_BASE_URL/files/<file_id>/status" \
  -H "X-API-Key: $MEMIC_API_KEY"
```

Wait until `status` is `ready`.

## 5. Search

```bash theme={null}
curl "$MEMIC_BASE_URL/search" \
  -H "X-API-Key: $MEMIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "what is our refund policy",
    "top_k": 5
  }'
```

## 6. Chat

```bash theme={null}
curl "$MEMIC_BASE_URL/chat" \
  -H "X-API-Key: $MEMIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "Summarize our refund policy"}
    ]
  }'
```

## What's next?

<Card title="API Reference" icon="book" href="/api-reference/introduction" horizontal>
  Every endpoint, every parameter, every error code — with a live try-it playground.
</Card>
