> For the complete documentation index, see [llms.txt](https://docs.lingoql.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lingoql.com/sub0/apis-abi/example-apis-abi.md).

# Example APIs (ABI)

Use these examples when you want a clear starting point fast.

Each example is small enough to copy and adapt.

### 1. User signup

This inserts a user, hashes the password, and returns a token.

```json
{
  "id": "user-signup-01",
  "resource": "user-signup",
  "tokenize": {
    "type": "JWT",
    "custom_claim_fields": ["id"],
    "expiration": 3600,
    "encryption_key": "$ENV.JWT_KEY",
    "property_name": "token"
  },
  "actionables": [
    {
      "id": 1,
      "mode": "QUERY",
      "sql_query": {
        "query": "INSERT INTO users (name, email, password, created_at, updated_at) VALUES ($1, $2, $3, $4, $5)",
        "unique": ["email"],
        "parameters": ["name", "email", "password", "$DATETIME", "$DATETIME"]
      },
      "hashables": [
        {
          "property": "password",
          "algorithm": "BCRYPT",
          "options": {
            "rounds_cost": 12,
            "salt": "$ENV.MY_HASHING_SALT"
          }
        }
      ]
    }
  ],
  "returnables": ["id", "name", "email", "token"]
}
```

### 2. Protected profile endpoint

This reads data for the authenticated user only.

```json
{
  "id": "user-profile-01",
  "resource": "user-profile",
  "tokenize": {
    "type": "JWT",
    "algorithm": "HS256",
    "encryption_key": "$ENV.JWT_KEY"
  },
  "protected": {
    "provide_as": "x-api-key",
    "extract_claims": ["id"]
  },
  "actionables": [
    {
      "id": 1,
      "mode": "QUERY",
      "sql_query": {
        "query": "SELECT id, name, email FROM users WHERE id = $1",
        "parameters": ["$PROTECTED.id"]
      }
    }
  ],
  "returnables": ["id", "name", "email"]
}
```

### 3. External API call

This sends a request to another service from inside the endpoint.

```json
{
  "id": "send-welcome-email-01",
  "resource": "send-welcome-email",
  "actionables": [
    {
      "id": 1,
      "mode": "HTTPREQUEST",
      "http": {
        "url": "https://api.sendgrid.com/send",
        "method": "POST",
        "headers": {
          "x-api-key": "$ENV.SENDGRID_API_KEY"
        },
        "request_body": {
          "sender": "$ENV.EMAIL_SENDER",
          "to": "$PAYLOAD.email",
          "message": "Hello World"
        }
      }
    }
  ]
}
```

### 4. Background webhook handler

This accepts a webhook and stores it without blocking the caller.

```json
{
  "id": "transactions-webhook-01",
  "resource": "transactions-webhook",
  "run_in_background": true,
  "actionables": [
    {
      "id": 1,
      "mode": "QUERY",
      "sql_query": {
        "query": "INSERT INTO transactions (txn_id, amount, metadata) VALUES ($1, $2, $3)",
        "parameters": ["txn_id", "amount", "metadata"]
      }
    }
  ]
}
```

### 5. Scheduled cleanup job

This runs on a schedule without client requests.

```json
{
  "id": "cleanup-01",
  "resource": "cleanup",
  "actionables": [
    {
      "id": 1,
      "mode": "QUERY",
      "run_in_background": true,
      "sql_query": {
        "query": "DELETE FROM sessions WHERE expires_at < $1",
        "parameters": ["$DATETIME"]
      },
      "cron_job": {
        "execution_interval": "0 0 0 * * *"
      }
    }
  ]
}
```

### Why these examples matter

These are not toy snippets.

They show the real ABI patterns behind production auth, data access, integrations, and async execution.

When you want fuller patterns, move to [Practical Examples](/sub0/apis-abi/practical-examples.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lingoql.com/sub0/apis-abi/example-apis-abi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
