Skip to main content
This page walks through common end-to-end workflows with the PG:AI API. Each flow includes the full sequence of API calls with examples. For request parameters and response schemas, see the endpoint pages below in the API tab sidebar.

Setup

Set your API key before running any example:
Generate keys in Settings → API Keys in your PG:AI workspace.

First request: search accounts

The simplest integration check — authenticate and list accounts in your workspace.
Response (200):
Send an empty body {} to return all accounts (paginated).

Add a company and wait for enrichment

Adding a company is async. You receive a public_operation_id and poll until enrichment completes.

Step 1: Submit the company

Response (202):
Provide at least one of company_name, domain, or id (existing PG:AI company UUID).

Step 2: Poll operation status

Poll until status is completed or failed. Typical intervals: 2–5 seconds.

Step 3: Read the enriched profile

Once complete, the operation result includes the company id (or use the id you already had):

Full Python example


Research an account

Combine account search, semantic search, and profile data for a research pipeline.

Step 1: Find the company

Step 2: Unified search across your workspace

Step 3: Company profile and relevance

Use GET /filters to discover filter metadata available for your workspace before building search UIs.

Find and enrich contacts

Step 1: Search contacts

Step 2: Enrich email or phone

Enrichment may be async — check the response for an operation id and poll GET /operations/{public_operation_id} if needed.

List canvases for a company

Use the workspace canvas list with a company_ids filter. This is the canonical pattern — prefer it over company-scoped list paths.
Or pass the filter in a clearer form:
Optional filters: contact_id, content_type, created_after, created_before. Fetch a single document with GET /canvas/{canvas_id}.

List territories


Check credit usage

Useful before batch enrichment or contact enrichment flows.

MCP instead of REST

For AI clients (Claude, Cursor, etc.), the MCP server exposes the same workspace data as tools — no need to wire every REST call yourself. See the Integrations tab for MCP setup, or connect to https://mcp.getpg.ai.

Error handling

All flows should handle standard HTTP status codes in production: See Authentication for permission scopes and rate limit headers.