Home / API integration examples

API integration examples

Build request sequences for rankings, audits, keywords, prompts and monitoring. Each workflow shows permissions, identifiers and retry handling.

On this page

Start with the outcome you need and follow the requests in order. Each workflow lists its required scopes.

Set LABRIKA_API_KEY. Take SITE_UUID and ENGINE_ID from the sites list and PROJECT_ID from the projects list. Set COST_ESTIMATE_ID and IDEMPOTENCY_KEY from cost_estimate_id and idempotency_key in the quote. Copy RUN_ID from the launch response. Set LIST_REVISION from list.revision in the result. After editing the list, update LIST_REVISION with revision from the PATCH response before applying it.

After a launch timeout, reuse the same Idempotency-Key and body. Check the key on 401 and permissions on 403. Read the conflict reason on 409. On 429, follow Retry-After when present.

Latest rankings

Read saved keyword rankings for the right region and search engine.

serp:read

Reading keyword positions requires an active Business or Agency subscription. Listing sites and collection dates is available with serp:read.

  1. GET /serp/sites?limit=10

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/serp/sites?limit=10" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  2. GET /serp/sites/$SITE_UUID/search-engines/$ENGINE_ID/dates?limit=5

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/serp/sites/$SITE_UUID/search-engines/$ENGINE_ID/dates?limit=5" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  3. GET /serp/sites/$SITE_UUID/search-engines/$ENGINE_ID/positions?collected_at=last&limit=20

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/serp/sites/$SITE_UUID/search-engines/$ENGINE_ID/positions?collected_at=last&limit=20" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
Response excerpt
{
  "data": [
    {
      "site_uuid": "d3c9e51b06a44e27831f205ceac20000",
      "host": "example.com",
      "search_engines": [
        {
          "id": 42,
          "engine_title": "Google"
        }
      ]
    }
  ]
}

Run a full audit

Keep the quote ID and read the launch stage using the site UUID.

site-audits:runmain-reports:read

  1. GET /main-reports/sites?limit=10

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/main-reports/sites?limit=10" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  2. POST /site-audits/sites/$SITE_UUID/cost

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/site-audits/sites/$SITE_UUID/cost" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      --data '{"pages_limit":500,"payment_option":"auto"}'
  3. POST /site-audits/sites/$SITE_UUID/run

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/site-audits/sites/$SITE_UUID/run" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
      --data-binary @- <<JSON
    {"cost_estimate_id":"${COST_ESTIMATE_ID:?}"}
    JSON
  4. GET /site-audits/sites/$SITE_UUID/progress

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/site-audits/sites/$SITE_UUID/progress" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
Response excerpt
{
  "data": {
    "cost_estimate_id": "ESTIMATE_FROM_COST",
    "idempotency_key": "KEY_FROM_COST",
    "page_credits": 500,
    "amount_minor": 0
  }
}

Keywords for a site

Read the result, edit the working list and apply the selected revision to the site's settings.

domain-keywords:run

From the quote, set PAYMENT_OPTION to ai_credits if credits_available is true, or money_balance if balance_available is true. If both are false, top up before starting. Reuse the same payment option when retrying a launch.

  1. POST /domain-keywords/cost

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/domain-keywords/cost" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      --data '{"domain":"example.com","keyword_count":80}'
  2. POST /domain-keywords/run

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/domain-keywords/run" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
      --data-binary @- <<JSON
    {"cost_estimate_id":"${COST_ESTIMATE_ID:?}","payment_option":"${PAYMENT_OPTION:?}"}
    JSON
  3. GET /domain-keywords/runs/$RUN_ID/progress

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/domain-keywords/runs/$RUN_ID/progress" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  4. GET /domain-keywords/runs/$RUN_ID

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/domain-keywords/runs/$RUN_ID" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  5. PATCH /domain-keywords/runs/$RUN_ID/list

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/domain-keywords/runs/$RUN_ID/list" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      -X PATCH \
      --data-binary @- <<JSON
    {"revision":${LIST_REVISION:?},"mode":"append","items":[{"text":"wholesale tea"}]}
    JSON
  6. POST /domain-keywords/runs/$RUN_ID/apply

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/domain-keywords/runs/$RUN_ID/apply" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      --data-binary @- <<JSON
    {"site_uuid":"${SITE_UUID:?}","revision":${LIST_REVISION:?}}
    JSON
Response excerpt
{
  "cost_estimate_id": "ESTIMATE_FROM_COST",
  "idempotency_key": "KEY_FROM_COST",
  "ai_credits": 40,
  "amount_minor": 20,
  "currency": "USD",
  "credits_available": true,
  "balance_available": true,
  "keyword_count": 80
}

Prompts for AI Visibility

Explain what the business offers and what it excludes. Choose 30–2,000 prompts in increments of 10.

prompt-suggestions:run

From the quote, set PAYMENT_OPTION to ai_credits if credits_available is true, or money_balance if balance_available is true. If both are false, top up before starting. Reuse the same payment option when retrying a launch.

  1. POST /prompt-suggestions/cost

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/prompt-suggestions/cost" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      --data '{"domain":"example.com","company_description":"We supply wholesale loose-leaf tea and tasting packs to cafés and independent retailers. We help customers plan their range and deliver regularly under contract.","exclusions":["Coffee","Coffee equipment","Retail purchases"],"prompt_count":30}'
  2. POST /prompt-suggestions/run

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/prompt-suggestions/run" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
      --data-binary @- <<JSON
    {"cost_estimate_id":"${COST_ESTIMATE_ID:?}","payment_option":"${PAYMENT_OPTION:?}"}
    JSON
  3. GET /prompt-suggestions/runs/$RUN_ID/progress

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/prompt-suggestions/runs/$RUN_ID/progress" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  4. GET /prompt-suggestions/runs/$RUN_ID

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/prompt-suggestions/runs/$RUN_ID" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  5. PATCH /prompt-suggestions/runs/$RUN_ID/list

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/prompt-suggestions/runs/$RUN_ID/list" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      -X PATCH \
      --data-binary @- <<JSON
    {"revision":${LIST_REVISION:?},"mode":"append","items":[{"text":"Where can cafés buy wholesale tea?"}]}
    JSON
  6. POST /prompt-suggestions/runs/$RUN_ID/apply

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/prompt-suggestions/runs/$RUN_ID/apply" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      --data-binary @- <<JSON
    {"site_uuid":"${SITE_UUID:?}","revision":${LIST_REVISION:?}}
    JSON
Response excerpt
{
  "cost_estimate_id": "ESTIMATE_FROM_COST",
  "idempotency_key": "KEY_FROM_COST",
  "ai_credits": 21,
  "amount_minor": 11,
  "currency": "USD",
  "credits_available": true,
  "balance_available": true
}

AI visibility

Find your projects for a domain before choosing whether to use one or create another. Start AI visibility at the confirmed price. Use the same Idempotency-Key returned by the quote. Proposed settings replace the project settings when you confirm.

sites:createai-visibility:run

Quote AI visibility using saved or proposed settings. Omit payment_option to see the cost in AI credits and in the account currency. No report starts at this step.

  1. GET /sites/by-domain?domain=example.com

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/sites/by-domain?domain=example.com" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  2. GET /ai-visibility/sites/$SITE_UUID/models

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/ai-visibility/sites/$SITE_UUID/models" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  3. POST /ai-visibility/sites/$SITE_UUID/cost

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/ai-visibility/sites/$SITE_UUID/cost" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      --data '{"settings":{"domain":"example.com","brand":"Acme","aliases":["Acme Studio"],"prompts":["Where can cafés order tea wholesale?"],"models":["chatgpt"],"competitors":[{"domain":"competitor.example","brand":"Rival Tea"}]}}'
  4. POST /ai-visibility/sites/$SITE_UUID/run

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/ai-visibility/sites/$SITE_UUID/run" \
      -H "Authorization: Bearer $LABRIKA_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
      --data-binary @- <<JSON
    {"cost_estimate_id":"${COST_ESTIMATE_ID:?}"}
    JSON
Response excerpt
{
  "data": {
    "cost_estimate_id": "ESTIMATE_FROM_COST",
    "idempotency_key": "KEY_FROM_COST",
    "ai_credits": 1,
    "money_equivalent_minor": 1,
    "can_start": true
  }
}

Website changes

Find the monitoring project and read its recent alerts.

diff-projects:readdiff-alerts:read

  1. GET /diff-projects?limit=10

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/diff-projects?limit=10" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"
  2. GET /diff-projects/$PROJECT_ID/alerts?limit=20

    curl --silent --show-error --fail-with-body "https://app.labrika.com/public-api/v1/diff-projects/$PROJECT_ID/alerts?limit=20" \
      -H "Authorization: Bearer $LABRIKA_API_KEY"

HTTP 202 means the request was accepted, not that processing finished. Save the returned identifier and check the state with the specified GET method. HTTP 200 when reading a state is not proof that the task succeeded: inspect status and error fields. Respect retry_after_seconds when returned.

The shared API/MCP usage budget, account money, subscription allowances and AI credits are separate resources. An estimate that does not charge money can still consume the technical usage budget. Before a paid operation, check the current estimate, payment option and response currency.