Search loads only when you use it. Browse all categories below.

Analytics and insights

Request provider insights

Ask the provider for insights for an account or one post over an optional date range (up to 366 days). Returns a request_id and, when cached, the result; otherwise poll sosoapi_get_provider_insight_status.

POST /analytics-api/provider-insights/request

Contract reviewed: · sha256:563d2d581da0ad29

Overview

Ask the provider for insights for an account or one post over an optional date range (up to 366 days). Returns a request_id and, when cached, the result; otherwise poll sosoapi_get_provider_insight_status.

A successful HTTP response can mean that a request was accepted rather than completed. For background work, save the returned ID and check the same operation until it finishes. A scheduled or accepted post is published only when the platform confirms it; a client timeout does not establish the result.

Authentication and permissions

Accepted credential classes
user_session, delegated_oauth, personal_access_token
Delegated capability
agent:operate
Minimum workspace role
viewer
Access scope
Resources this user is authorized to access
All-workspace consent required
No
Changes state
No
When the operation is complete
provider-native result or explicit unavailable reason

A token can use only the rights held by its owner. Each request checks workspace membership, resource ownership, selected workspaces and granted capabilities. Core and full profiles change which tools are displayed; they do not grant access.

Request fields

Required means required inside its parent object and selected branch. A required child does not make an optional parent required. Rules and field names below are copied from the contract.

Request fields
Field / branchType / requiredConstraints
$objectRequired in parent
  • additionalProperties: false
workspace_idstringRequired in parent
  • format: "uuid"
  • pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
social_account_idstringRequired in parent
  • format: "uuid"
  • pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
resource_kindstringRequired in parent
  • enum: ["account","post"]
provider_resource_idstringOptional / item
  • minLength: 1
  • maxLength: 512
start_datestringOptional / item
  • pattern: "^\\d{4}-\\d{2}-\\d{2}$"
end_datestringOptional / item
  • pattern: "^\\d{4}-\\d{2}-\\d{2}$"
include_audiencebooleanOptional / item—
refreshbooleanOptional / item—
Complete JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "social_account_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "resource_kind": {
      "type": "string",
      "enum": [
        "account",
        "post"
      ]
    },
    "provider_resource_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512
    },
    "start_date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "end_date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "include_audience": {
      "type": "boolean"
    },
    "refresh": {
      "type": "boolean"
    }
  },
  "required": [
    "workspace_id",
    "social_account_id",
    "resource_kind"
  ],
  "additionalProperties": false
}

Response and completion

Success HTTP statuses: 200, 202. When the operation is complete: provider-native result or explicit unavailable reason.

A successful HTTP response can mean that a request was accepted rather than completed. For background work, save the returned ID and check the same operation until it finishes. A scheduled or accepted post is published only when the platform confirms it; a client timeout does not establish the result.

Required means required inside its parent object and selected branch. A required child does not make an optional parent required. Rules and field names below are copied from the contract.

Response and completion
Field / branchType / requiredConstraints
$objectRequired in parent—
contract_versionstringRequired in parent
  • const: "provider-insights/v1"
request_idstringRequired in parent
  • format: "uuid"
  • pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
statusstringRequired in parent
  • enum: ["queued","completed"]
cache_statusstringRequired in parent
  • enum: ["hit","miss","bypassed"]
poll_after_msintegerRequired in parent
  • minimum: 0
  • maximum: 60000
resultobjectOptional / item—
result.contract_versionstringRequired in parent
  • const: "provider-insights/v1"
result.request_idstringRequired in parent
  • format: "uuid"
  • pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
result.platformstringRequired in parent
  • enum: ["facebook","instagram","threads","youtube"]
result.resourceobjectRequired in parent—
result.resource.kindstringRequired in parent
  • enum: ["account","post"]
result.resource.social_account_idstringRequired in parent
  • format: "uuid"
  • pattern: "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
result.resource.provider_resource_idstring | nullRequired in parent—
result.resource.provider_resource_idanyOf 1stringRequired in parent—
result.resource.provider_resource_idanyOf 2nullRequired in parent—
result.provider_api_versionstringRequired in parent
  • minLength: 1
  • maxLength: 100
result.fetched_atstringRequired in parent
  • format: "date-time"
  • pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
result.statusstringRequired in parent
  • enum: ["available","partial","unavailable"]
result.availabilityarrayRequired in parent
  • minItems: 1
  • maxItems: 64
result.availability[]objectOptional / item—
result.availability[].scopestringRequired in parent
  • minLength: 1
  • maxLength: 200
result.availability[].statusstringRequired in parent
  • enum: ["available","partial","not_returned","unsupported","permission_required","threshold_not_met","no_data","failed"]
result.availability[].reasonstringOptional / item
  • minLength: 1
  • maxLength: 2000
result.provider_dataany JSON value | nullRequired in parent—
result.provider_dataanyOf 1any JSON valueRequired in parent—
result.provider_dataanyOf 2nullRequired in parent—
result.requested_date_rangeobject | nullRequired in parent—
result.requested_date_rangeanyOf 1objectRequired in parent—
result.requested_date_range.start_dateanyOf 1stringRequired in parent
  • pattern: "^\\d{4}-\\d{2}-\\d{2}$"
result.requested_date_range.end_dateanyOf 1stringRequired in parent
  • pattern: "^\\d{4}-\\d{2}-\\d{2}$"
result.requested_date_rangeanyOf 2nullRequired in parent—
result.cacheobjectRequired in parent—
result.cache.authoritativebooleanRequired in parent
  • const: false
result.cache.statusstringRequired in parent
  • enum: ["stored","hit","bypassed"]
result.cache.expires_atstringRequired in parent
  • format: "date-time"
  • pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
Complete JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract_version": {
      "type": "string",
      "const": "provider-insights/v1"
    },
    "request_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "completed"
      ]
    },
    "cache_status": {
      "type": "string",
      "enum": [
        "hit",
        "miss",
        "bypassed"
      ]
    },
    "poll_after_ms": {
      "type": "integer",
      "minimum": 0,
      "maximum": 60000
    },
    "result": {
      "type": "object",
      "properties": {
        "contract_version": {
          "type": "string",
          "const": "provider-insights/v1"
        },
        "request_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "platform": {
          "type": "string",
          "enum": [
            "facebook",
            "instagram",
            "threads",
            "youtube"
          ]
        },
        "resource": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "account",
                "post"
              ]
            },
            "social_account_id": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "provider_resource_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "kind",
            "social_account_id",
            "provider_resource_id"
          ]
        },
        "provider_api_version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "fetched_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        "status": {
          "type": "string",
          "enum": [
            "available",
            "partial",
            "unavailable"
          ]
        },
        "availability": {
          "minItems": 1,
          "maxItems": 64,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "scope": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "status": {
                "type": "string",
                "enum": [
                  "available",
                  "partial",
                  "not_returned",
                  "unsupported",
                  "permission_required",
                  "threshold_not_met",
                  "no_data",
                  "failed"
                ]
              },
              "reason": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2000
              }
            },
            "required": [
              "scope",
              "status"
            ]
          }
        },
        "provider_data": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ]
        },
        "requested_date_range": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "start_date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                },
                "end_date": {
                  "type": "string",
                  "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                }
              },
              "required": [
                "start_date",
                "end_date"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "cache": {
          "type": "object",
          "properties": {
            "authoritative": {
              "type": "boolean",
              "const": false
            },
            "status": {
              "type": "string",
              "enum": [
                "stored",
                "hit",
                "bypassed"
              ]
            },
            "expires_at": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            }
          },
          "required": [
            "authoritative",
            "status",
            "expires_at"
          ]
        }
      },
      "required": [
        "contract_version",
        "request_id",
        "platform",
        "resource",
        "provider_api_version",
        "fetched_at",
        "status",
        "availability",
        "provider_data",
        "requested_date_range",
        "cache"
      ]
    }
  },
  "required": [
    "contract_version",
    "request_id",
    "status",
    "cache_status",
    "poll_after_ms"
  ]
}

Errors and safe retries

Check the HTTP status and response body. A 400 validation error may contain a ZodError; handler errors use error, message and code fields. Keep request_id or x-request-id for diagnosis, without credentials. Fix 401/403 access errors before retrying, and follow Retry-After for 429. If a write is uncertain or returns 5xx, read the existing result first. Reuse an idempotency key only where supported; retry behaviour varies by operation and does not guarantee exactly-once delivery.

Troubleshooting guide

Examples

These examples use fictional values checked against the schemas. Replace the IDs with ones you are authorized to use, the media with ready assets and the dates with your confirmed publishing time. Check the account’s eligibility before submitting a write. This page sends no API requests.

Set SOSOAPI_ACCESS_TOKEN on your server to a credential accepted by this operation, and keep it out of browser code. For an agent, use sosoapi auth login to sign in through the browser and let the CLI refresh its credentials.

request.json

{
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "social_account_id": "11111111-1111-4111-8111-111111111111",
  "resource_kind": "account"
}

cURL

curl --request POST \
  "https://gqeshlawtcexsapabaui.supabase.co/functions/v1/analytics-api/provider-insights/request" \
  -H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json

JavaScript

// Server-side JavaScript. Do not print tokens or credential-bearing responses.
const token = process.env.SOSOAPI_ACCESS_TOKEN;
if (!token) throw new Error("Set an accepted credential for this operation");
const response = await fetch("https://gqeshlawtcexsapabaui.supabase.co/functions/v1/analytics-api/provider-insights/request", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
  body: JSON.stringify({
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "social_account_id": "11111111-1111-4111-8111-111111111111",
  "resource_kind": "account"
})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.

CLI

npx sosoapi api post /analytics-api/provider-insights/request < request.json

Synthetic response example

{
  "contract_version": "provider-insights/v1",
  "request_id": "11111111-1111-4111-8111-111111111111",
  "status": "queued",
  "cache_status": "hit",
  "poll_after_ms": 0
}

MCP: sosoapi_request_provider_insights