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

# Migrations API

> Create and manage app migrations via the Nometria API.

The migrations API lets you programmatically create migrations (connect an app source) and check their status.

## List migrations

```http theme={null}
GET /v1/migrations
```

Returns all migrations in your account.

**Query parameters:**

| Parameter | Type    | Description                                                     |
| --------- | ------- | --------------------------------------------------------------- |
| `limit`   | integer | Number of results (default: 20, max: 100)                       |
| `cursor`  | string  | Pagination cursor from previous response                        |
| `status`  | string  | Filter by status: `pending`, `processing`, `complete`, `failed` |

**Example request:**

```bash theme={null}
curl https://api.nometria.com/v1/migrations \
  -H "Authorization: Bearer <your-api-key>"
```

**Example response:**

```json theme={null}
{
  "data": [
    {
      "id": "mig_abc123",
      "project_id": "proj_xyz789",
      "source": "github",
      "repo": "your-org/your-app",
      "branch": "main",
      "framework": "react-vite",
      "status": "complete",
      "created_at": "2025-01-15T10:30:00Z",
      "completed_at": "2025-01-15T10:35:00Z"
    }
  ],
  "pagination": {
    "has_more": false,
    "next_cursor": null
  }
}
```

***

## Get migration

```http theme={null}
GET /v1/migrations/{migration_id}
```

Returns a single migration by ID.

**Example request:**

```bash theme={null}
curl https://api.nometria.com/v1/migrations/mig_abc123 \
  -H "Authorization: Bearer <your-api-key>"
```

**Example response:**

```json theme={null}
{
  "data": {
    "id": "mig_abc123",
    "project_id": "proj_xyz789",
    "source": "github",
    "repo": "your-org/your-app",
    "branch": "main",
    "framework": "react-vite",
    "database": {
      "type": "supabase",
      "project_id": "xxxxxxxxxxxx"
    },
    "status": "complete",
    "created_at": "2025-01-15T10:30:00Z",
    "completed_at": "2025-01-15T10:35:00Z",
    "logs_url": "https://api.nometria.com/v1/migrations/mig_abc123/logs"
  }
}
```

***

## Create migration

```http theme={null}
POST /v1/migrations
```

Start a new migration from a GitHub repository.

**Request body:**

| Field       | Type   | Required     | Description                                                                            |
| ----------- | ------ | ------------ | -------------------------------------------------------------------------------------- |
| `source`    | string | Yes          | Connection type: `github` or `zip`                                                     |
| `repo`      | string | Yes (github) | GitHub repo in `owner/repo` format                                                     |
| `branch`    | string | No           | Branch to deploy from (default: `main`)                                                |
| `framework` | string | No           | Override framework detection: `react-vite`, `nextjs`, `node-express`, `python-fastapi` |
| `env_vars`  | object | No           | Key-value pairs of environment variables                                               |
| `database`  | object | No           | Database configuration (see below)                                                     |
| `domain`    | string | No           | Custom domain                                                                          |
| `region`    | string | No           | AWS region (default: `us-east-1`)                                                      |

**Database object:**

```json theme={null}
{
  "type": "supabase",           // "supabase" or "appwrite"
  "action": "create",          // "create" (new project) or "connect" (existing)
  "url": "https://xxx.supabase.co",     // Required if action is "connect"
  "service_key": "eyJ..."       // Required if action is "connect"
}
```

**Example request:**

```bash theme={null}
curl -X POST https://api.nometria.com/v1/migrations \
  -H "Authorization: Bearer <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "source": "github",
    "repo": "your-org/your-app",
    "branch": "main",
    "env_vars": {
      "NEXT_PUBLIC_SUPABASE_URL": "https://xxx.supabase.co",
      "NEXT_PUBLIC_SUPABASE_ANON_KEY": "eyJ...",
      "STRIPE_SECRET_KEY": "sk_live_..."
    },
    "database": {
      "type": "supabase",
      "action": "create"
    },
    "domain": "app.yourcompany.com",
    "region": "us-east-1"
  }'
```

**Example response:**

```json theme={null}
{
  "data": {
    "id": "mig_newone123",
    "status": "processing",
    "project_id": "proj_newproject",
    "created_at": "2025-01-15T12:00:00Z"
  }
}
```

The migration runs asynchronously. Poll `GET /v1/migrations/{id}` to check status, or use webhooks.

***

## Migration logs

```http theme={null}
GET /v1/migrations/{migration_id}/logs
```

Stream build and migration logs.

**Example request:**

```bash theme={null}
curl https://api.nometria.com/v1/migrations/mig_abc123/logs \
  -H "Authorization: Bearer <your-api-key>"
```

**Example response:**

```json theme={null}
{
  "data": {
    "logs": [
      { "timestamp": "2025-01-15T10:30:01Z", "level": "info", "message": "Starting migration..." },
      { "timestamp": "2025-01-15T10:30:05Z", "level": "info", "message": "Framework detected: React + Vite" },
      { "timestamp": "2025-01-15T10:30:10Z", "level": "info", "message": "Provisioning EC2 instance in us-east-1..." },
      { "timestamp": "2025-01-15T10:31:45Z", "level": "info", "message": "Instance ready. Running build..." },
      { "timestamp": "2025-01-15T10:33:20Z", "level": "info", "message": "Build complete. Starting app..." },
      { "timestamp": "2025-01-15T10:34:00Z", "level": "success", "message": "App healthy. Migration complete." }
    ]
  }
}
```

***

## Migration statuses

| Status       | Description                                       |
| ------------ | ------------------------------------------------- |
| `pending`    | Migration is queued                               |
| `processing` | Infrastructure being provisioned, app being built |
| `complete`   | Migration finished, app is live                   |
| `failed`     | Migration failed — check logs for details         |
