API Documentation

Complete reference for all available API endpoints. Authenticate with your API key to get started.

Login to Access Your API Key

Your personal API key is required to authenticate requests. Log in to view, copy, or regenerate your key.

Authentication

All API requests require authentication via your API key.

Include your API key in every request using one of these methods:

# Recommended: X-API-Key header
X-API-Key: your-api-key-here

# Alternative: Authorization Bearer token
Authorization: Bearer your-api-key-here
HTTP StatusMeaning
401Missing API key
403Invalid or expired API key
429Rate limit exceeded (60 req/min for trigger endpoints)
POST /api/token-usage

Token Usage Tracking

Track AI model token consumption and costs from your n8n workflows.

Quick Setup

Enable dashboard editing, click Connect to n8n, then copy the pre-configured HTTP Request node — your API key is already filled in.

Request

Method: POST
URL: https://invokati.com/api/token-usage
Auth: X-API-Key header

Request Body

{
  "n8n_base_url": "{{ $env.WEBHOOK_URL.split('/webhook')[0] }}",
  "workflow_id":  "{{ $workflow.id }}",
  "execution_id": "{{ $execution.id }}",
  "model_id":     "gpt-4",
  "input_tokens": {{ $json.usage.prompt_tokens }},
  "output_tokens": {{ $json.usage.completion_tokens }}
}

Fields

FieldRequiredDescription
n8n_base_urlYesBase URL of your n8n instance
workflow_idYesn8n workflow UUID ($workflow.id)
execution_idYesn8n execution ID ($execution.id)
model_idYesAI model name e.g. gpt-4, claude-3-opus
input_tokensYesNumber of prompt/input tokens
output_tokensYesNumber of completion/output tokens

Token field names by AI provider:

  • OpenAI: $json.usage.prompt_tokens / $json.usage.completion_tokens
  • Anthropic: $json.usage.input_tokens / $json.usage.output_tokens
  • Google: $json.usageMetadata.promptTokenCount / $json.usageMetadata.candidatesTokenCount

Response (201)

{
  "status": "success",
  "message": "Token usage recorded successfully",
  "id": "259",
  "data": {
    "workflow_id": "b9NLgJV0oXIpXSsr",
    "execution_id": "551",
    "model_id": "gpt-4",
    "input_tokens": 399,
    "output_tokens": 288,
    "total_tokens": 687,
    "input_cost": 0.01197,
    "output_cost": 0.01728,
    "total_cost": 0.02925,
    "model_found": true,
    "model_label": "GPT-4"
  }
}

GET /api/token-usage/{workflow_id}/stats

Retrieve aggregated token usage statistics for a workflow.

{
  "status": "success",
  "workflow_id": "abc123",
  "stats": {
    "total_records": 150,
    "total_tokens": 210000,
    "total_cost": 8.85
  }
}
POST /api/trigger-webhook

Webhook Trigger

Trigger an n8n workflow from the dashboard. Proxies the request to your n8n webhook endpoint. Rate limited to 60 requests/minute.

Quick Setup

Enable dashboard editing, click Connect to n8n, then use Copy Trigger Node to get a fully pre-configured webhook node for your n8n canvas.

Trigger Request Body

{
  "endpoint": "https://n8n.example.com/webhook/your-path",
  "source": "dashboard",
  "data": {
    "custom_key": "custom_value"
  }
}
FieldRequiredDescription
endpointYesFull n8n webhook URL to call
sourceNoOrigin label, defaults to dashboard
dataNoAdditional payload to forward to n8n

n8n receives this payload

{
  "triggered_at": "2025-01-21T10:30:00Z",
  "source": "dashboard",
  "user_id": 42,
  "username": "john.doe",
  "data": {}
}

n8n Webhook Setup

HTTP Method: POST
Path: invokati-trigger/[installation_id]/[workflow_id]
Respond: Immediately

POST /api/poll-execution

Poll Execution Status

Poll n8n for the status of the most recent execution of a workflow. Automatically called by the dashboard after triggering.

{
  "nid": 123,
  "triggered_after": "2025-01-21T10:30:00Z"
}
FieldRequiredDescription
nidYesDrupal workflow node ID
triggered_afterNoISO timestamp — only match executions after this time

Response statuses

statusis_completeMeaning
waitingfalseExecution not yet started, keep polling
successtrueExecution completed successfully
errortrueExecution failed or crashed

Media API

Create and manage media items (images, videos, audio, files) from n8n workflows. Media items are scoped to your client group.

MethodEndpointAuthDescription
POST/api/mediaAPI KeyCreate a media item
GET/api/media/listSessionList media items for your group
GET/api/media/{id}SessionGet a single media item
PATCH/api/media/{id}SessionUpdate media item fields
DELETE/api/media/{id}API KeyDelete a media item
POST/automation/media/createAPI KeyCreate from n8n with human-interaction flag
GET/api/media/statsSessionMedia statistics for dashboard widget

Create Media — POST /api/media

{
  "title": "Product Hero Video",
  "media_type": "video",
  "url": "https://youtube.com/watch?v=xyz",
  "thumbnail_url": "https://img.youtube.com/vi/xyz/hqdefault.jpg",
  "description": "Main hero video for product launch",
  "tags": "product, launch, hero",
  "installation_id": 45,
  "workflow_id": "abc123",
  "execution_id": "exec-789",
  "human_interaction": true,
  "allow_regenerate": true,
  "automation_status": "pending"
}

Media Fields Reference

FieldRequiredDescription
titleYesDisplay name for the media item
media_typeYesvideo, image, audio, or file
urlNoSource URL — provider metadata auto-resolved for YouTube, Vimeo, etc.
thumbnail_urlNoPreview image URL (auto-resolved from YouTube/Vimeo if omitted)
embed_urlNoEmbeddable URL (auto-resolved)
download_urlNoDirect download URL, defaults to url
sourceNoSource label e.g. YouTube, Vimeo
durationNoVideo/audio duration string
file_sizeNoHuman-readable file size
width / heightNoPixel dimensions (integers)
descriptionNoFree-text description
tagsNoComma-separated tags
installation_idNoDrupal Installation node ID
workflow_idNon8n workflow UUID — used to resolve client group
execution_idNon8n execution ID — required for human-interaction resume
human_interactionNotrue to require approve/deny review before workflow resumes
allow_regenerateNotrue to show a Regenerate button in the review panel
automation_statusNoInitial status: pending (default), approved, denied
collection_idNoID of an existing Collection entity to assign this media item to
collection_nameNoCollection title — auto-creates the collection if it doesn't exist. Takes precedence over collection_id

List Media Query Params — GET /api/media/list

ParamDescription
media_typeFilter by type: video, image, audio, file
automation_statusFilter by status: pending, approved, denied
human_interactionSet to 1 to return only items requiring review
group_idFilter to a specific client group ID
searchSearch in title, source, and tags
collection_idFilter to media items in a specific collection

Response (201)

{
  "success": true,
  "id": 42,
  "media_type": "video",
  "automation_status": "pending",
  "installation_id": 45,
  "workflow_id": "abc123",
  "message": "Media item created successfully."
}

Collections API

Manage collections — named groups for organizing media items. Collections are scoped to your team. Use collection_name in media creation calls to auto-create collections.

MethodEndpointAuthDescription
GET/api/collectionsSessionList all collections for your team
POST/api/collectionsSessionCreate a new collection
GET/api/collections/{id}SessionGet a single collection
PUT/api/collections/{id}SessionUpdate title or description
DELETE/api/collections/{id}SessionDelete a collection

Create Collection — POST /api/collections

{
  "title": "March Social Media Campaign",
  "description": "All assets for Q1 social push"
}

List Response

{
  "collections": [
    {
      "id": 1,
      "title": "March Social Media Campaign",
      "description": "All assets for Q1 social push",
      "team_id": 5,
      "media_count": 12,
      "created": 1710000000,
      "changed": 1710100000
    }
  ],
  "count": 1
}

Auto-create from n8n: Pass collection_name in any POST /api/media payload and the collection will be created automatically if it does not exist. The resolved collection_id is returned in the media create response.

Leads API

Create and manage leads from n8n workflows. Leads are scoped to your client group with automatic duplicate detection.

MethodEndpointDescription
POST/api/leadsCreate a lead (API Key auth)
GET/api/leads/recentRecent leads for dashboard widget
GET/api/leads/listFull lead list with filters
GET/api/leads/{id}Get single lead
PATCH/api/leads/{id}Update lead fields
DELETE/api/leads/{id}Delete lead (API Key auth)

Create Lead — POST /api/leads

Duplicate detection is automatic — same email within the same group triggers dedup behavior. Control with on_duplicate query param.

POST /api/leads?on_duplicate=update

{
  "first_name": "Jane",
  "last_name": "Doe",
  "email": "jane@example.com",
  "phone": "+1 555-0100",
  "company_name": "Acme Corp",
  "job_title": "VP Marketing",
  "website": "https://acme.com",
  "industry": "Technology",
  "company_size": "51-200",
  "annual_revenue": "$5M-$10M",
  "location": "San Francisco, CA",
  "lead_source": "Website Form",
  "status": "New",
  "lead_score": 75,
  "budget_confirmed": false,
  "pain_points": "Manual reporting takes too long",
  "timeline": "Q2 2025",
  "utm_source": "google",
  "utm_medium": "cpc",
  "utm_campaign": "spring-promo",
  "installation_id": 45,
  "workflow_id": "abc123",
  "execution_id": "exec-789",
  "human_interaction": false,
  "automation_status": "pending"
}

Required Fields

FieldTypeDescription
first_nameRequiredLead's first name
last_nameRequiredLead's last name
emailRequiredEmail address — used for duplicate detection

Duplicate Handling

Add ?on_duplicate= to the query string:

ValueBehavior
ignoreDefault — return existing lead ID, no update
updateUpdate non-empty fields on the existing lead
createAlways create a new lead, skip dedup check

Default Statuses

New Working Attempted Connected Qualified Nurture Unqualified

List Query Params — GET /api/leads/list

ParamDescription
statusFilter by lead status
sourceFilter by lead_source value
group_idFilter to a specific client group
searchSearch in name, email, and company
limitMax results for /recent endpoint (1–50, default 5)

Response (201)

{
  "success": true,
  "id": 101,
  "status": "New",
  "message": "Lead created successfully."
}

Lead Pipeline & Custom Fields

Manage custom lead statuses, custom fields, view configuration, and bulk operations for your team's CRM pipeline.

Lead Statuses

MethodEndpointDescription
GET/api/lead-statusesList all statuses for your team (includes defaults)
POST/api/lead-statusesCreate a custom status (requires label, optional color)
PATCH/api/lead-statuses/{id}Update label or color of a custom status
DELETE/api/lead-statuses/{id}Delete a custom status (built-in statuses cannot be deleted)
POST/api/lead-statuses/reorderReorder statuses — body: {"ids": [3,1,4,2]}

Custom Fields

MethodEndpointDescription
GET/api/lead-custom-fieldsList custom fields defined for your team
POST/api/lead-custom-fieldsCreate a custom field (requires label and field_type)
PATCH/api/lead-custom-fields/{id}Update field label, options, or required flag
DELETE/api/lead-custom-fields/{id}Delete a custom field and all its values

Supported field_type values: text, textarea, number, date, select, checkbox, url. Pass options as a JSON array for select fields. Custom field values are read and written via the standard /api/leads/{id} PATCH endpoint using the field's machine name.

View Configuration

MethodEndpointDescription
GET/api/leads/view-configGet the current user's saved column visibility and order
PUT/api/leads/view-configSave column visibility/order — body: {"columns": [...]}

Bulk Operations — POST /api/leads/bulk

{
  "action": "update_status",
  "ids": [101, 102, 103],
  "status": "Qualified"
}

Supported actions: update_status, delete.

Custom Payloads API

Store arbitrary structured data from n8n workflows. Use custom payloads for any output that doesn't fit the Lead or Media models.

MethodEndpointDescription
POST/api/payloadsCreate a custom payload (API Key auth)
GET/api/payloads/listList payloads with filters
GET/api/payloads/{id}Get single payload
PATCH/api/payloads/{id}Update payload
DELETE/api/payloads/{id}Delete payload (API Key auth)
POST/automation/payload/createCreate from n8n with human-interaction flag

Create Payload — POST /api/payloads

{
  "title": "Monthly SEO Report",
  "task_type": "seo-report",
  "payload": {
    "domain": "example.com",
    "keywords": ["n8n automation", "workflow tool"],
    "backlinks": 342,
    "domain_authority": 45
  },
  "installation_id": 45,
  "workflow_id": "abc123",
  "execution_id": "exec-789",
  "human_interaction": true,
  "allow_regenerate": true,
  "automation_status": "pending"
}

Fields Reference

FieldRequiredDescription
titleYesDisplay name for the payload
task_typeNoCategory label for grouping e.g. seo-report, content-brief. Defaults to generic
payloadNoAny JSON object or string — stored as JSON
installation_idNoDrupal Installation node ID
workflow_idNon8n workflow UUID
execution_idNon8n execution ID — required for human-interaction resume
human_interactionNotrue to pause workflow until a human approves/denies
allow_regenerateNotrue to show a Regenerate button in the review panel
automation_statusNopending (default), approved, denied

List Query Params — GET /api/payloads/list

ParamDescription
task_typeFilter by task type string
automation_statusFilter by status
human_interactionSet to 1 for items requiring review
group_idFilter to a specific client group
searchSearch in title and task_type

Human Interaction (Automation Review)

Pause n8n workflows for human review. When approved, denied, or regenerated, the platform automatically resumes the paused n8n execution via the n8n resume API.

How it works

  1. Your n8n workflow creates a Lead, Media, or Custom Payload with human_interaction: true and execution_id
  2. n8n pauses using a Wait node listening on the resume webhook
  3. A reviewer on the platform clicks Approve, Deny, or Regenerate
  4. The platform calls POST /automation/approve (or deny/regenerate)
  5. The platform POSTs to {n8n_host}/rest/executions/{execution_id}/resume with the decision
  6. n8n resumes and processes the decision

Review Endpoints

MethodEndpointActionRequired Permission
POST/automation/approveSet status to approved and resume n8nreview automation content
POST/automation/denySet status to denied and resume n8nreview automation content
POST/automation/regenerateSet status to regenerate and resume n8nreview automation content

Request Body (all three endpoints)

{
  "entity_id": 42,
  "entity_type": "custom_payload",
  "execution_id": "exec-789",
  "installation_id": 45,
  "notes": "Looks good, approved for production."
}
FieldRequiredDescription
entity_idYesID of the entity to review
entity_typeYeslead, media_item, or custom_payload
execution_idNo*n8n execution ID — required to resume the workflow
installation_idNo*Installation node ID — required to resume the workflow
notesNoReviewer notes — saved as a note and forwarded to n8n

* If omitted, the platform uses the values stored on the entity. Both are needed to resume n8n.

n8n receives this resume payload

{
  "decision": "approved",
  "notes": "Looks good, approved for production.",
  "entity_id": 42,
  "entity_type": "custom_payload"
}

Response

{
  "success": true,
  "entity_id": 42,
  "entity_type": "custom_payload",
  "action": "approved",
  "automation_status": "approved",
  "n8n_resumed": true
}

Create via Automation Endpoints

Convenience endpoints for creating entities from n8n with human-interaction preset to pending. Authentication via API Key.

EndpointCreatesRequired Fields
/automation/payload/createCustomPayloadtitle
/automation/media/createMediaItemtitle, media_type

Both accept the same fields as their respective /api/ counterparts plus an optional group_id to override the auto-resolved client group.

POST /api/push/executions

Push Execution Data

For self-hosted n8n instances that push execution telemetry to this platform instead of the platform polling the n8n API. Requires Bearer token auth.

Register Your n8n Instance First

POST /api/installs/register
Authorization: Bearer your-api-key-here
{
  "instance_id": "my-n8n-001",
  "host": "https://n8n.yourdomain.com",
  "api_key": "n8n-api-key-here",
  "title": "Production n8n"
}

Push Execution Data

POST /api/push/executions
Authorization: Bearer your-api-key-here
{
  "installation_id": 45,
  "workflow_id": "abc123",
  "execution_data": { }
}

Execution data is stored as {installation_id}-{workflow_id}.json and used by the workflow dashboard instead of polling the n8n API.

Get Already-Imported Workflows

GET /api/installed/{installation_node_id}

Returns a list of n8n workflow IDs already imported from a given installation — useful to avoid duplicates during bulk import.

Powered by
n8n front-end + analytics

Help & Feedback

We'd love to hear from you

How can we improve Invokati?