openapi: "3.0.3" info: title: AmpleData API version: "1.0.0" description: AmpleData enrichment API servers: - url: /api/v1 security: - BearerAuth: [] components: securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: ColumnType: type: string enum: [string, number, boolean, date] JobType: type: string enum: [enrichment, imputation] JobStatus: type: string enum: [PENDING, RUNNING, PAUSED, CANCELLED, COMPLETED] RowStage: type: string enum: [ PENDING, SERP_FETCHED, DECISION_MADE, CRAWLED, ENRICHED, COMPLETED, FAILED, CANCELLED, ] ColumnMetadata: type: object required: [name, type, job_type] properties: name: type: string type: $ref: "#/components/schemas/ColumnType" job_type: $ref: "#/components/schemas/JobType" description: type: string nullable: true FieldConfidenceInfo: type: object required: [score, reason] properties: score: type: number format: double reason: type: string SignedURLRequest: type: object required: [contentType, length] properties: contentType: type: string enum: [text/csv, application/json] length: type: integer minimum: 1 headers: type: array items: type: string description: CSV column headers, used to generate an AI name for the source SignedURLResponse: type: object required: [url, sourceId] properties: url: type: string sourceId: type: string format: uuid JobSummary: type: object required: [job_id, status, total_rows, source_id, created_at] properties: job_id: type: string status: $ref: "#/components/schemas/JobStatus" total_rows: type: integer source_id: type: string format: uuid created_at: type: string format: date-time started_at: type: string format: date-time nullable: true JobListResponse: type: object required: [jobs, total_count] properties: jobs: type: array items: $ref: "#/components/schemas/JobSummary" total_count: type: integer JobProgressResponse: type: object required: [job_id, total_rows, rows_by_stage, started_at, status] properties: job_id: type: string total_rows: type: integer rows_by_stage: type: object additionalProperties: type: integer started_at: type: string status: $ref: "#/components/schemas/JobStatus" EnrichmentResult: type: object required: [key, extracted_data, sources, extraction_history] properties: key: type: string extracted_data: type: object additionalProperties: true confidence: type: object additionalProperties: $ref: "#/components/schemas/FieldConfidenceInfo" nullable: true sources: type: array items: type: string extraction_history: type: array items: $ref: "#/components/schemas/ExtractionHistoryEntry" error: type: string nullable: true ExtractionHistoryEntry: type: object required: [attempt_number, extracted_data, sources, reasoning] properties: attempt_number: type: integer extracted_data: type: object additionalProperties: true confidence: type: object additionalProperties: $ref: "#/components/schemas/FieldConfidenceInfo" nullable: true sources: type: array items: type: string reasoning: type: string PaginationInfo: type: object required: [total, offset, limit, has_more] properties: total: type: integer offset: type: integer limit: type: integer has_more: type: boolean RowProgressItem: type: object required: [key, stage, updated_at, extraction_history] properties: key: type: string stage: $ref: "#/components/schemas/RowStage" extracted_data: type: object additionalProperties: true nullable: true confidence: type: object additionalProperties: $ref: "#/components/schemas/FieldConfidenceInfo" nullable: true sources: type: array items: type: string nullable: true extraction_history: type: array items: $ref: "#/components/schemas/ExtractionHistoryEntry" error: type: string nullable: true updated_at: type: string format: date-time RowsProgressResponse: type: object required: [rows, pagination] properties: rows: type: array items: $ref: "#/components/schemas/RowProgressItem" pagination: $ref: "#/components/schemas/PaginationInfo" SelectKeyRequest: type: object required: [source_id] properties: source_id: type: string format: uuid columns_metadata: type: array items: $ref: "#/components/schemas/ColumnMetadata" nullable: true SelectKeyResponse: type: object required: [selected_key, all_keys, reasoning] properties: selected_key: type: string all_keys: type: array items: type: string reasoning: type: string SourceJobSummary: type: object required: [job_id, status, total_rows, created_at] properties: job_id: type: string status: $ref: "#/components/schemas/JobStatus" total_rows: type: integer key_columns: type: array items: type: string nullable: true key_column_description: type: string nullable: true columns_metadata: type: array items: $ref: "#/components/schemas/ColumnMetadata" nullable: true created_at: type: string format: date-time started_at: type: string format: date-time nullable: true SourceSummary: type: object required: [source_id, type, created_at, job_count] properties: source_id: type: string format: uuid name: type: string nullable: true type: type: string created_at: type: string format: date-time job_count: type: integer latest_job_status: $ref: "#/components/schemas/JobStatus" nullable: true SourceDetail: type: object required: [source_id, type, created_at, jobs] properties: source_id: type: string format: uuid type: type: string created_at: type: string format: date-time jobs: type: array items: $ref: "#/components/schemas/SourceJobSummary" SourceListResponse: type: object required: [sources, total_count] properties: sources: type: array items: $ref: "#/components/schemas/SourceSummary" total_count: type: integer EnrichRequest: type: object required: [columns_metadata] properties: columns_metadata: type: array items: $ref: "#/components/schemas/ColumnMetadata" minItems: 1 key_columns: type: array items: type: string nullable: true key_column_description: type: string nullable: true row_limit: type: integer minimum: 1 nullable: true description: Maximum number of rows to process. Processes all rows if not set. from_template_id: type: string nullable: true description: | Optional. ID of the template this job was launched from, for attribution/analytics only. The actual config is taken from key_columns and columns_metadata in this request - this field does not affect execution. EnrichResponse: type: object required: [job_id] properties: job_id: type: string CreateSubscriptionRequest: type: object required: [tier_id, success_url, cancel_url] properties: tier_id: type: string success_url: type: string cancel_url: type: string UpgradeSubscriptionRequest: type: object required: [tier_id] properties: tier_id: type: string CreateCheckoutResponse: type: object required: [checkout_url, session_id] properties: checkout_url: type: string session_id: type: string SubscriptionStatusResponse: type: object required: [tokens_used, tokens_included, cancel_at_period_end] properties: tier: type: string nullable: true tokens_used: type: integer format: int64 tokens_included: type: integer format: int64 cancel_at_period_end: type: boolean current_period_start: type: string format: date-time nullable: true current_period_end: type: string format: date-time nullable: true TierResponse: type: object required: [ id, display_name, monthly_price_cents, included_tokens, overage_price_cents_decimal, ] properties: id: type: string display_name: type: string monthly_price_cents: type: integer format: int64 included_tokens: type: integer format: int64 overage_price_cents_decimal: type: string UserResponse: type: object required: [first_name, last_name, email] properties: first_name: type: string last_name: type: string email: type: string TemplateType: type: string enum: [system_template, user_defined_template] TemplateColumnMetadata: type: object required: [name, type, operation] properties: name: type: string type: $ref: "#/components/schemas/ColumnType" operation: type: string description: type: string nullable: true Template: type: object required: [id, name, description, entity_type, type, key_columns, columns_metadata] properties: id: type: string format: uuid name: type: string description: type: string entity_type: type: string type: $ref: "#/components/schemas/TemplateType" key_columns: type: array items: type: string columns_metadata: type: array items: $ref: "#/components/schemas/TemplateColumnMetadata" owned_by: type: string nullable: true TemplateListResponse: type: object required: [templates, total_count] properties: templates: type: array items: $ref: "#/components/schemas/Template" total_count: type: integer ErrorResponse: type: object required: [message] properties: message: type: string paths: /me: get: operationId: getMe summary: Get the current authenticated user's profile tags: [users] responses: "200": description: User profile content: application/json: schema: $ref: "#/components/schemas/UserResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /webhooks/stripe: post: operationId: handleStripeWebhook summary: Handle Stripe webhook events security: [] tags: [billing, internal] requestBody: required: true content: application/octet-stream: schema: type: string format: binary parameters: - name: Stripe-Signature in: header required: true schema: type: string responses: "200": description: Webhook processed "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Invalid signature content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /enrichment-signed-url: post: operationId: uploadFileForEnrichment summary: Create a pending enrichment job and get a signed upload URL tags: [jobs] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SignedURLRequest" responses: "200": description: Signed URL generated content: application/json: schema: $ref: "#/components/schemas/SignedURLResponse" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /sources: get: operationId: listSources summary: List sources for the authenticated user tags: [sources] parameters: - name: offset in: query schema: type: integer default: 0 - name: limit in: query schema: type: integer default: 50 responses: "200": description: List of sources content: application/json: schema: $ref: "#/components/schemas/SourceListResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /sources/{sourceID}: get: operationId: getSource summary: Get source details with all enrichment runs tags: [sources] parameters: - name: sourceID in: path required: true schema: type: string format: uuid responses: "200": description: Source detail content: application/json: schema: $ref: "#/components/schemas/SourceDetail" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Forbidden content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Source not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /sources/{sourceID}/data: get: operationId: GetSourceData summary: Get the raw CSV data for a source tags: [sources] parameters: - name: sourceID in: path required: true schema: type: string format: uuid responses: "200": description: Raw CSV data content: application/json: schema: type: object properties: headers: type: array items: type: string rows: type: array items: type: array items: type: string required: [headers, rows] "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Forbidden content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Source not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /sources/{sourceID}/enrich: post: operationId: enrichSource summary: Start a new enrichment run for a source tags: [sources] parameters: - name: sourceID in: path required: true schema: type: string format: uuid requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/EnrichRequest" responses: "200": description: Enrichment started content: application/json: schema: $ref: "#/components/schemas/EnrichResponse" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "402": description: Payment required content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Forbidden content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Source not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /jobs/{jobID}/cancel: post: operationId: cancelJob summary: Cancel a running enrichment job tags: [jobs] parameters: - name: jobID in: path required: true schema: type: string responses: "200": description: Job cancelled content: application/json: schema: type: object required: [message] properties: message: type: string "404": description: Job not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /jobs/{jobID}/progress: get: operationId: getJobProgress summary: Get progress summary for a job tags: [jobs] parameters: - name: jobID in: path required: true schema: type: string responses: "200": description: Job progress content: application/json: schema: $ref: "#/components/schemas/JobProgressResponse" "404": description: Job not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /jobs/{jobID}/results: get: operationId: getJobResults summary: Get enrichment results for a job tags: [jobs] parameters: - name: jobID in: path required: true schema: type: string - name: start in: query schema: type: integer default: 0 - name: limit in: query schema: type: integer default: 0 responses: "200": description: Enrichment results content: application/json: schema: type: array items: $ref: "#/components/schemas/EnrichmentResult" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /jobs/{jobID}/rows: get: operationId: getRowsProgress summary: Get per-row progress for a job tags: [jobs] parameters: - name: jobID in: path required: true schema: type: string - name: offset in: query schema: type: integer default: 0 - name: limit in: query schema: type: integer default: 50 maximum: 100 - name: stage in: query schema: type: string default: all - name: sort in: query schema: type: string default: updated_at_desc responses: "200": description: Row progress content: application/json: schema: $ref: "#/components/schemas/RowsProgressResponse" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /select-key: post: operationId: selectKey summary: Use AI to select the best key column from a source's CSV tags: [jobs, internal] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SelectKeyRequest" responses: "200": description: Selected key content: application/json: schema: $ref: "#/components/schemas/SelectKeyResponse" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "403": description: Forbidden content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Source not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /subscribe: post: operationId: createSubscriptionCheckout summary: Create a Stripe checkout session for a subscription tags: [billing, internal] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateSubscriptionRequest" responses: "200": description: Checkout session created content: application/json: schema: $ref: "#/components/schemas/CreateCheckoutResponse" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /subscription: get: operationId: getSubscriptionStatus summary: Get the current user's subscription status tags: [billing, internal] responses: "200": description: Subscription status content: application/json: schema: $ref: "#/components/schemas/SubscriptionStatusResponse" "400": description: User not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /subscription/upgrade: post: operationId: upgradeSubscription summary: Upgrade the current user's subscription to a higher tier tags: [billing, internal] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpgradeSubscriptionRequest" responses: "200": description: Subscription upgraded content: application/json: schema: type: object required: [message] properties: message: type: string "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /subscription/cancel: post: operationId: cancelSubscription summary: Cancel the current user's subscription tags: [billing, internal] responses: "200": description: Subscription cancelled content: application/json: schema: type: object required: [message] properties: message: type: string "400": description: No active subscription content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /subscription/portal: post: operationId: createPortalSession summary: Create a Stripe customer portal session tags: [billing, internal] parameters: - in: query name: return_url required: true schema: type: string responses: "200": description: Portal session URL content: application/json: schema: type: object required: [url] properties: url: type: string "400": description: User not found or missing Stripe customer content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /templates: get: operationId: listTemplates summary: List all templates (system + user-defined) tags: [templates] responses: "200": description: List of templates content: application/json: schema: $ref: "#/components/schemas/TemplateListResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Internal server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /tiers: get: operationId: listTiers summary: List available subscription tiers tags: [billing] responses: "200": description: List of tiers content: application/json: schema: type: array items: $ref: "#/components/schemas/TierResponse"