> 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/practical-examples/wallet-backend-async-jobs-and-webhooks.md).

# Wallet backend: Async jobs and webhooks

Use this page when the core API works and the operational work starts.

### Best for

Notifications, provider callbacks, and scheduled maintenance.

### What it shows

* Background HTTP calls
* Verified webhook handling
* Cron-based cleanup

### Use this when

You want slow or external work to stop blocking your main request path.

### Pattern 1. Queue a receipt email

Use this when a user action should return fast and notify later.

```json
{
  "id": "wallet-send-receipt-01",
  "resource": "send-transaction-receipt",
  "tokenize": {
    "type": "JWT",
    "algorithm": "HS256",
    "encryption_key": "$ENV.JWT_SECRET_KEY"
  },
  "protected": {
    "provide_as": "x-access-token",
    "extract_claims": ["id"]
  },
  "actionables": [
    {
      "id": 1,
      "mode": "HTTPREQUEST",
      "run_in_background": true,
      "queue": {
        "delay": 10,
        "priority": 0
      },
      "http": {
        "url": "https://api.lambahq.com/v1/action/$ENV.LAMBA_CUSTOMER_ID",
        "method": "POST",
        "headers": {
          "Content-Type": "application/json",
          "Authorization": "Basic $ENV.LAMBA_API_KEY"
        },
        "request_body": {
          "service": "low_mail",
          "low_mail_input": {
            "integration": "any",
            "subject": "$PAYLOAD.subject",
            "message": "$PAYLOAD.message",
            "recipients": "$PAYLOAD.recipients"
          }
        }
      }
    }
  ]
}
```

### Pattern 2. Verify a webhook before updating a transaction

Use this when a payment provider calls back into your app.

```json
{
  "id": "wallet-provider-webhook-01",
  "resource": "provider-webhook",
  "webhook": {
    "verifications": {
      "HeaderTokenVerifier": {
        "header_key": "$HEADER.X-GITLAB-TOKEN",
        "secret_key": "$ENV.MY_GITLAB_TOKEN"
      },
      "IpAllowListVerifier": {
        "allowed_ips": "$ENV.ALLOWED_IPS"
      },
      "composition_strategy_mode": "ALL"
    }
  },
  "actionables": [
    {
      "id": 1,
      "mode": "QUERY",
      "run_in_background": true,
      "sql_query": {
        "query": "UPDATE transactions SET status = $1, updated_at = $2::timestamptz WHERE id = $3",
        "parameters": ["status", "$DATETIME", "transaction_id"]
      }
    }
  ]
}
```

### Pattern 3. Clear expired CSRF tokens on a schedule

Use this when temporary auth state should not grow forever.

```json
{
  "id": "wallet-cleanup-csrf-01",
  "resource": "cleanup-csrf-tokens",
  "actionables": [
    {
      "id": 1,
      "mode": "QUERY",
      "run_in_background": true,
      "sql_query": {
        "query": "DELETE FROM csrf_token_store WHERE created_at < NOW() - INTERVAL '1 day'"
      },
      "cron_job": {
        "execution_interval": "0 0 * * * *"
      }
    }
  ]
}
```

Use [Queueing](/sub0/apis-abi/queueing.md), [Cron Jobs](/sub0/apis-abi/cron-jobs.md), and [Webhooks](/sub0/apis-abi/webhooks.md) when you need the deeper rules behind each pattern.


---

# 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/practical-examples/wallet-backend-async-jobs-and-webhooks.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.
