Skip to content

    AI answer collection and runs

    Estimate collection credits

    Quotes the credits for a collection.

    POST /v2/runs

    • Body workflow is collect.
    • Body estimate is true. Default is false.

    Authentication and access

    Authentication
    Bearer API key
    Scopes
    collections:write
    Roles
    editor, owner, service
    Plans
    Optimizer, Analyzer
    Credits
    The estimate uses zero credits.
    Billing access
    Required

    Read data.estimated_credits for the estimate and data.maximum_credits for the upper limit.

    Check the price per delivered answer for the sources in your request.

    Parameters

    Request parameters
    NameWhereTypeRequiredDescription
    Idempotency-KeyheaderstringYesFor 7 days, sending the same key and body for the same account and operation returns the original response. Changing the body for that key returns HTTP 409.

    Request body

    {
      "answer_mode": "standard",
      "brand_id": "00000000-0000-4000-8000-000000000001",
      "estimate": true,
      "market": {
        "country": "US",
        "language": "example"
      },
      "max_units": 0,
      "prompt_ids": [
        "00000000-0000-4000-8000-000000000001"
      ],
      "sources": [
        {
          "mode": "ui_normal",
          "platform": "chatgpt"
        }
      ],
      "workflow": "collect"
    }
    Request body fields 1
    NameTypeRequiredDescription
    all_locationsbooleanNo
    allow_country_levelbooleanNoAllow a country-level answer when the source cannot apply the requested location.
    answer_mode"standard" | "new"NoUse standard for the normal answer or new to request a new answer.
    brand_idstring (uuid)Yes
    estimatetrueYes
    location_idsarray of string (uuid)No
    marketobjectYes
    market.citystring | null | nullNo
    market.countrystringYes
    market.languagestringYes
    market.latitudenumber | nullNo
    market.location_idstring (uuid) | nullNo
    market.longitudenumber | nullNo
    market.postal_codestring | nullNo
    market.regionstring | null | nullNo
    max_unitsintegerNo
    prompt_idsarray of string (uuid)Yes
    repeat_countintegerNo
    sourcesarray of objectYes
    sources[].device"desktop" | "mobile" | "unknown"No
    sources[].mode"ui_normal" | "ui_search" | "api_normal" | "api_web" | "ai_mode" | "ai_overview" | "organic_search"Yes
    sources[].platform"chatgpt" | "gemini" | "claude" | "perplexity" | "google" | "bing" | "brave" | "meta_ai" | "grok" | "universal"Yes
    sources[].providerstringNoOptional source label for the selected platform and mode. An unsupported combination is rejected before the job starts.
    workflow"collect"Yes

    Request examples

    Set AEO_API_BASE_URL to https://api.aeoapi.dev and AEO_API_KEY to your server-side API key. Set the other environment variables to the values for your request.

    Save the JSON request body as request.json. Replace sample IDs, revisions and other values with your own.

    curl --fail-with-body -X POST "$AEO_API_BASE_URL/v2/runs" \
      -H "Authorization: Bearer $AEO_API_KEY" \
      -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
      -H "Content-Type: application/json" \
      --data-binary @request.json
    import json
    from pathlib import Path
    from os import environ
    from aeo_sdk import AeoClient
    
    body = json.loads(Path("request.json").read_text())
    
    with AeoClient(environ["AEO_API_KEY"], base_url=environ["AEO_API_BASE_URL"]) as client:
        response = client.v2_post_runs(
            body=body,
            idempotency_key=environ["IDEMPOTENCY_KEY"],
        )
        print(response.body)
    import { AeoClient } from "@aeoapi/aeo-sdk";
    import { readFile } from "node:fs/promises";
    
    const client = new AeoClient(process.env.AEO_API_KEY!, {
      baseUrl: process.env.AEO_API_BASE_URL!,
    });
    const body = JSON.parse(await readFile("request.json", "utf8"));
    const response = await client.v2PostRuns(
      body,
      {
        idempotencyKey: process.env.IDEMPOTENCY_KEY!,
      },
    );
    console.log(response.body);

    Responses

    HTTP 200

    Collection credit estimate.

    application/json

    Response fields are listed below.

    HTTP 200 response fields 1
    NameTypeRequiredDescription
    dataobjectYesThe requested result. See the fields below for its contents.
    data.answer_countintegerYes
    data.brand_idstring (uuid)YesIdentifies the brand this result belongs to.
    data.eligible_enginesarray of objectYes
    data.eligible_engines[].sourceobjectYes
    data.eligible_engines[].unenforced_controlsarray of stringYes
    data.estimated_creditsintegerYesThe expected credit cost for this selection.
    data.location_totalsarray of objectNo
    data.location_totals[].eligible_enginesarray of objectNo
    data.location_totals[].eligible_engines[].sourceobjectConditional
    data.location_totals[].eligible_engines[].unenforced_controlsarray of stringConditional
    data.location_totals[].estimated_creditsintegerConditional
    data.location_totals[].location_idstring (uuid)Conditional
    data.location_totals[].marketobjectConditional
    data.location_totals[].market.citystring | null | nullNo
    data.location_totals[].market.countrystringConditional
    data.location_totals[].market.languagestringConditional
    data.location_totals[].market.latitudenumber | nullNo
    data.location_totals[].market.location_idstring (uuid)No
    data.location_totals[].market.longitudenumber | nullNo
    data.location_totals[].market.postal_codestring | nullNo
    data.location_totals[].market.regionstring | null | nullNo
    data.location_totals[].maximum_creditsintegerConditional
    data.location_totals[].prompt_countintegerConditional
    data.maximum_creditsintegerYesThe upper credit estimate for this selection.
    data.prompt_countintegerYes
    metaobjectYesInformation about this response, including any warnings or pagination details.
    meta.as_ofstring (date-time)YesThe point in time that the response represents.
    meta.cohort_versionstring | nullNoIdentifies the version of the group used to calculate the results.
    meta.collected_atstring (date-time) | nullYesWhen the data was collected, if available.
    meta.metric_versionstring | nullNoThe version of the metric definition used for these results.
    meta.next_cursorstring | nullYesWhen present, pass this value as cursor to request the next page with the same filters.
    meta.next_refresh_atstring (date-time) | nullYes
    meta.request_idstring (uuid)YesKeep this ID when reporting a problem with the request.
    meta.restricted_fieldsarray of stringNoFields that your current access does not allow the API to return.
    meta.rights_filteredbooleanYesIndicates whether access rights affected the returned data.
    meta.schema_version"1.0"YesThe version of the response format.
    meta.stalebooleanYes
    meta.warningsarray of stringYesRead these notes for limitations that affect the results.

    Errors

    Read code and message in the error response. Keep request_id when you contact support.

    AI answer collection and runs reference