NextPay Docs
API Reference

Auth

Auth API endpoints

POST /auth/device-code

Create a device code for CLI authentication

Request Body

FieldTypeRequiredDescription
intentstringNo

Example Request

{
  "intent": "login"
}

Responses

200 — Device code created

FieldTypeRequiredDescription
codestringYes
verification_urlstringYes
expires_atnumberYes
{
  "code": "A1B2C3",
  "verification_url": "https://nextpay-v3-dev.nextfinancial.io/auth/device?code=A1B2C3",
  "expires_at": 1742472000
}

Example

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"intent":"login"}' \
  https://api.nextpay.world/v1/auth/device-code

GET /auth/device-code/{code}

Poll device code status

Path Parameters

ParameterTypeRequiredDescription
codestringYesThe 6-character device code

Responses

200 — Device code status

FieldTypeRequiredDescription
statusstringYes
tokenstringNo
{
  "status": "pending"
}

Example

curl \
  https://api.nextpay.world/v1/auth/device-code/A1B2C3

POST /auth/token

Exchange API key for a session JWT

Send a Bearer token in the Authorization header with an API key (npk_...) to receive a JWT.

Responses

200 — JWT token

FieldTypeRequiredDescription
okbooleanYes
dataobjectYes
{
  "ok": true,
  "data": {
    "token": "eyJhbGciOiJSUzI1NiIs...",
    "user_id": "usr_abc123"
  }
}

401 — Invalid API key

FieldTypeRequiredDescription
okbooleanYes
errorobjectYes
{
  "ok": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid API key"
  }
}

Example

curl -X POST \
  https://api.nextpay.world/v1/auth/token

GET /auth/me

Get current authenticated user

Authentication: Bearer token required

Responses

200 — Current user info

FieldTypeRequiredDescription
okbooleanYes
dataobjectYes
{
  "ok": true,
  "data": {
    "id": "usr_abc123",
    "email": "don@nextfinancial.io",
    "name": "Don Masakayan"
  }
}

401 — Not authenticated

FieldTypeRequiredDescription
okbooleanYes
errorobjectYes
{
  "ok": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Not authenticated"
  }
}

Example

curl \
  -H "Authorization: Bearer YOUR_TOKEN" \
  https://api.nextpay.world/v1/auth/me

On this page