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

# Agent Onboarding

> API-first account creation and non-interactive skill installation for autonomous agents

Use this guide when an AI agent needs to onboard without browser prompts.

## Prerequisites

* Base URL: `https://apigcp.trynia.ai/v2`
* `nia-wizard` installed or runnable with `npx`.

## Flow Overview

### New Users

1. Create account with `POST /v2/auth/signup` — returns a read-only API key and sends a 6-digit verification code to email.
2. Verify the account with `POST /v2/auth/verify` — upgrades the API key to full access.
3. Install Nia skill in non-interactive mode using `nia-wizard skill add`.

### Returning Users

1. Request a verification code with `POST /v2/auth/login`.
2. Exchange the code for a full-access API key with `POST /v2/auth/login/verify`.

## Create Account (API-First)

```bash theme={null}
curl -sS -X POST "https://apigcp.trynia.ai/v2/auth/signup" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "agent@example.com",
    "organization_name": "Agent Org",
    "first_name": "Agent",
    "last_name": "Runner",
    "idempotency_key": "signup-agent-001"
  }'
```

Response includes:

* `api_key` (read-only until verified)
* `api_key_id`
* `user_id`
* `organization_id`
* `verified` (false)

## Verify Account

Use the 6-digit code sent to your email:

```bash theme={null}
curl -sS -X POST "https://apigcp.trynia.ai/v2/auth/verify" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <read-only-api-key>" \
  -d '{
    "code": "123456"
  }'
```

On success, the API key is upgraded from read-only to full access.

## Returning User Login (Passwordless)

### Step 1: Request verification code

```bash theme={null}
curl -sS -X POST "https://apigcp.trynia.ai/v2/auth/login" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "agent@example.com"
  }'
```

### Step 2: Exchange code for API key

```bash theme={null}
curl -sS -X POST "https://apigcp.trynia.ai/v2/auth/login/verify" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "agent@example.com",
    "code": "123456"
  }'
```

Response includes a fresh `api_key` with full access.

## Install Nia Skill Non-Interactively

```bash theme={null}
npx nia-wizard skill add \
  --api-key "<api-key-from-auth-endpoint>" \
  --source nozomio-labs/nia-skill \
  --non-interactive \
  --ci
```

Optional target pinning:

```bash theme={null}
npx nia-wizard skill add \
  --api-key "<api-key-from-auth-endpoint>" \
  --target codex \
  --non-interactive \
  --ci
```

## End-To-End Script (Headless)

```bash theme={null}
#!/usr/bin/env bash
set -euo pipefail

BASE_URL="https://apigcp.trynia.ai/v2"
EMAIL="agent@example.com"
ORG_NAME="Agent Org"

# Step 1: Sign up (returns read-only API key)
SIGNUP_JSON=$(curl -sS -X POST "$BASE_URL/auth/signup" \
  -H "Content-Type: application/json" \
  -d "{\"email\":\"$EMAIL\",\"organization_name\":\"$ORG_NAME\"}")

API_KEY=$(echo "$SIGNUP_JSON" | jq -r '.api_key')

# Step 2: Verify with email code (upgrades key to full access)
read -rp "Enter 6-digit verification code: " CODE

curl -sS -X POST "$BASE_URL/auth/verify" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d "{\"code\":\"$CODE\"}"

# Step 3: Install skill
npx nia-wizard skill add --api-key "$API_KEY" --non-interactive --ci
```

<Warning>
  Handle credentials and generated API keys as secrets. Do not print them to shared logs.
</Warning>

## Reference

See API Reference for these endpoints:

* `POST /auth/signup`
* `POST /auth/verify`
* `POST /auth/login`
* `POST /auth/login/verify`
* `POST /auth/resend-code`
