{"openapi":"3.1.0","info":{"title":"Hanbai API","version":"1.0.0","description":"Send email, manage sending domains, contacts, suppressions, webhooks and broadcasts. Resend-compatible where it overlaps. Authenticate with a Bearer API key (hb_live_… / hb_test_…) or an OAuth 2.1 access token. hb_test_ keys simulate sends; API and MCP live sending require a paid plan. The same operations are available as MCP tools at /api/mcp.","contact":{"url":"https://hanb.ai/developers"}},"servers":[{"url":"https://hanb.ai"}],"externalDocs":{"url":"https://hanb.ai/developers","description":"Developer documentation"},"security":[{"bearerAuth":[]}],"tags":[{"name":"Account"},{"name":"Emails"},{"name":"Domains"},{"name":"Contacts"},{"name":"Suppressions"},{"name":"Broadcasts"},{"name":"Webhooks"}],"paths":{"/api/v1/me":{"get":{"summary":"Introspect the API key","operationId":"getMe","tags":["Account"],"security":[{"bearerAuth":[]}],"x-scopes":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyInfo"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/usage":{"get":{"summary":"Plan usage","description":"Emails sent in the rolling month vs the plan limit, and contacts vs the plan limit.","operationId":"getUsage","tags":["Account"],"security":[{"bearerAuth":[]}],"x-scopes":[],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Usage"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/emails":{"get":{"summary":"List emails","operationId":"listEmails","tags":["Emails"],"security":[{"bearerAuth":["emails:read"]}],"x-scopes":["emails:read"],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"cursor","in":"query","description":"next_cursor from the previous page","schema":{"type":"string"}},{"name":"status","in":"query","schema":{"type":"string","enum":["queued","scheduled","sending","sent","delivered","bounced","complained","failed","canceled"]}},{"name":"mode","in":"query","schema":{"type":"string","enum":["live","test"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Email"}},"has_more":{"type":"boolean"},"next_cursor":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"summary":"Send an email","description":"Sends now, or stores for later when scheduled_at is in the future. Suppressed recipients are rejected (422 recipient_suppressed); live sends count against the plan quota (429 quota_exceeded).","operationId":"sendEmail","tags":["Emails"],"security":[{"bearerAuth":["emails:send"]}],"x-scopes":["emails:send"],"parameters":[{"name":"Idempotency-Key","in":"header","schema":{"type":"string"},"description":"Replays the first response for 24h."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendEmailRequest"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"provider_message_id":{"type":"string"},"status":{"type":"string"},"scheduled_at":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/emails/batch":{"post":{"summary":"Send up to 100 emails","operationId":"sendBatch","tags":["Emails"],"security":[{"bearerAuth":["emails:send"]}],"x-scopes":["emails:send"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"array","maxItems":100,"items":{"$ref":"#/components/schemas/SendEmailRequest"}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/emails/{id}":{"get":{"summary":"Get an email","operationId":"getEmail","tags":["Emails"],"security":[{"bearerAuth":["emails:read"]}],"x-scopes":["emails:read"],"parameters":[{"name":"id","in":"path","required":true,"description":"Email id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Email"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}},"patch":{"summary":"Reschedule a scheduled email","operationId":"rescheduleEmail","tags":["Emails"],"security":[{"bearerAuth":["emails:send"]}],"x-scopes":["emails:send"],"parameters":[{"name":"id","in":"path","required":true,"description":"Email id","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["scheduled_at"],"properties":{"scheduled_at":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/emails/{id}/cancel":{"post":{"summary":"Cancel a scheduled email","operationId":"cancelEmail","tags":["Emails"],"security":[{"bearerAuth":["emails:send"]}],"x-scopes":["emails:send"],"parameters":[{"name":"id","in":"path","required":true,"description":"Email id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"const":"canceled"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/domains":{"get":{"summary":"List sending domains","operationId":"listDomains","tags":["Domains"],"security":[{"bearerAuth":["domains:read"]}],"x-scopes":["domains:read"],"parameters":[{"name":"brand_id","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Domain"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"summary":"Add a sending domain","operationId":"createDomain","tags":["Domains"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string"},"region":{"type":"string"},"brand_id":{"type":"string"},"provider":{"type":"string"}}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Domain"},"dns_records":{"type":"array","items":{"type":"object"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/domains/{id}":{"get":{"summary":"Get a domain","operationId":"getDomain","tags":["Domains"],"security":[{"bearerAuth":["domains:read"]}],"x-scopes":["domains:read"],"parameters":[{"name":"id","in":"path","required":true,"description":"Domain id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Domain"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}},"patch":{"summary":"Update domain tracking","operationId":"updateDomain","tags":["Domains"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Domain id","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"track_opens":{"type":"boolean"},"track_clicks":{"type":"boolean"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Domain"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}},"delete":{"summary":"Delete a domain","operationId":"deleteDomain","tags":["Domains"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Domain id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deleted"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/domains/{id}/verify":{"post":{"summary":"Verify a domain","operationId":"verifyDomain","tags":["Domains"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Domain id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"verified":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Domain"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/domains/{id}/audit":{"get":{"summary":"Live DNS audit (SPF/DKIM/DMARC/MX/Return-Path)","operationId":"auditDomain","tags":["Domains"],"security":[{"bearerAuth":["domains:read"]}],"x-scopes":["domains:read"],"parameters":[{"name":"id","in":"path","required":true,"description":"Domain id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/domains/{id}/cloudflare-setup":{"post":{"summary":"Create DNS records via a Cloudflare API token","operationId":"cloudflareSetup","tags":["Domains"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Domain id","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["api_token"],"properties":{"api_token":{"type":"string"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/contacts":{"get":{"summary":"List contacts","operationId":"listContacts","tags":["Contacts"],"security":[{"bearerAuth":["contacts:read"]}],"x-scopes":["contacts:read"],"parameters":[{"name":"brand_id","in":"query","schema":{"type":"string"}},{"name":"status","in":"query","schema":{"type":"string","enum":["active","unsubscribed","bounced","complained"]}},{"name":"email","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"total":{"type":"integer"},"brand_id":{"type":"string"},"has_more":{"type":"boolean"},"next_offset":{"type":["integer","null"]}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"summary":"Add or update a contact","description":"Creates the contact, or updates only the supplied fields of an existing contact with the same email in the brand.","operationId":"upsertContact","tags":["Contacts"],"security":[{"bearerAuth":["contacts:write"]}],"x-scopes":["contacts:write"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"unsubscribed":{"type":"boolean"},"brand_id":{"type":"string"},"source":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Contact"}}}}}},"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Contact"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/contacts/{id}":{"get":{"summary":"Get a contact","operationId":"getContact","tags":["Contacts"],"security":[{"bearerAuth":["contacts:read"]}],"x-scopes":["contacts:read"],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Contact"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}},"patch":{"summary":"Update a contact","operationId":"updateContact","tags":["Contacts"],"security":[{"bearerAuth":["contacts:write"]}],"x-scopes":["contacts:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"unsubscribed":{"type":"boolean"},"status":{"type":"string","enum":["active","unsubscribed","bounced","complained"]}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Contact"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}},"delete":{"summary":"Delete a contact","operationId":"deleteContact","tags":["Contacts"],"security":[{"bearerAuth":["contacts:write"]}],"x-scopes":["contacts:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deleted"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/suppressions":{"get":{"summary":"List suppressed addresses","operationId":"listSuppressions","tags":["Suppressions"],"security":[{"bearerAuth":["contacts:read"]}],"x-scopes":["contacts:read"],"parameters":[{"name":"email","in":"query","schema":{"type":"string"}},{"name":"reason","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Suppression"}},"total":{"type":"integer"},"has_more":{"type":"boolean"},"next_offset":{"type":["integer","null"]}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"summary":"Suppress an address","operationId":"createSuppression","tags":["Suppressions"],"security":[{"bearerAuth":["contacts:write"]}],"x-scopes":["contacts:write"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string"},"reason":{"type":"string","enum":["manual","unsubscribe","bounce","complaint"]}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Suppression"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/suppressions/{id}":{"delete":{"summary":"Remove a suppression","operationId":"deleteSuppression","tags":["Suppressions"],"security":[{"bearerAuth":["contacts:write"]}],"x-scopes":["contacts:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Suppression id or URL-encoded email","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean"},"id":{"type":"string"},"email":{"type":"string"},"reason":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/broadcasts/preview":{"post":{"summary":"Preview a broadcast (dry run)","description":"Sends nothing. Returns recipient/suppressed counts, quota and a confirm_token (10 minutes, bound to org, brand, subject and content).","operationId":"previewBroadcast","tags":["Broadcasts"],"security":[{"bearerAuth":["broadcasts:send"]}],"x-scopes":["broadcasts:send"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastRequest"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BroadcastPreview"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/broadcasts":{"post":{"summary":"Send a broadcast to a brand's active contacts","description":"Optional confirm_token from /api/v1/broadcasts/preview: when present it must be valid for this brand, subject and content, and it is single-use (a replay returns the first response).","operationId":"sendBroadcast","tags":["Broadcasts"],"security":[{"bearerAuth":["broadcasts:send"]}],"x-scopes":["broadcasts:send"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BroadcastRequest"},{"type":"object","properties":{"confirm_token":{"type":"string"}}}]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"recipients":{"type":"integer"},"sent":{"type":"integer"},"failed":{"type":"integer"},"suppressed":{"type":"integer"},"warmup_capped":{"type":"integer"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/webhooks":{"get":{"summary":"List webhook endpoints","operationId":"listWebhooks","tags":["Webhooks"],"security":[{"bearerAuth":["domains:read"]}],"x-scopes":["domains:read"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"summary":"Create a webhook endpoint","operationId":"createWebhook","tags":["Webhooks"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri","description":"Public https URL"},"events":{"type":"array","items":{"type":"string","enum":["email.delivered","email.bounced","email.complained","email.opened","email.clicked","email.inbound"]}}}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Webhook"},"signing_secret":{"type":"string","description":"Shown once"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"422":{"$ref":"#/components/responses/ValidationError"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/webhooks/{id}":{"patch":{"summary":"Update a webhook endpoint","operationId":"updateWebhook","tags":["Webhooks"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook id","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"enabled":{"type":"boolean"}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Webhook"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}},"delete":{"summary":"Delete a webhook endpoint","operationId":"deleteWebhook","tags":["Webhooks"],"security":[{"bearerAuth":["domains:write"]}],"x-scopes":["domains:write"],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook id","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deleted"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"hb_live_… / hb_test_… API key or OAuth access token","description":"Scopes: emails:send, emails:read, domains:read, domains:write, inbound:read, contacts:read, contacts:write, broadcasts:send. OAuth metadata: https://hanb.ai/.well-known/oauth-authorization-server"}},"responses":{"Unauthorized":{"description":"Missing, invalid, expired or revoked key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"insufficient_scope, account_inactive or plan_upgrade_required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"ValidationError":{"description":"Validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Conflict":{"description":"Conflict (e.g. idempotency key or confirm_token reuse)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"rate_limit_exceeded or quota_exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","required":["statusCode","name","message"],"properties":{"statusCode":{"type":"integer"},"name":{"type":"string"},"message":{"type":"string"}},"additionalProperties":true},"KeyInfo":{"type":"object","properties":{"object":{"const":"api_key"},"api_key_id":{"type":"string"},"organization_id":{"type":"string"},"organization_name":{"type":["string","null"]},"mode":{"type":"string","enum":["live","test"]},"scopes":{"type":"array","items":{"type":"string"}},"plan":{"type":"string"},"default_brand_id":{"type":["string","null"]},"rate_limit_per_min":{"type":"integer"}}},"Usage":{"type":"object","properties":{"object":{"const":"usage"},"plan":{"type":"string"},"key_mode":{"type":"string"},"period":{"type":"object","properties":{"start":{"type":"string"},"end":{"type":"string"},"basis":{"type":"string"}}},"emails":{"type":"object","properties":{"sent":{"type":"integer"},"limit":{"type":["integer","null"]},"remaining":{"type":["integer","null"]},"test_mode_sent":{"type":"integer"}}},"contacts":{"type":"object","properties":{"total":{"type":"integer"},"active":{"type":"integer"},"limit":{"type":["integer","null"]},"remaining":{"type":["integer","null"]}}}}},"SendEmailRequest":{"type":"object","required":["from","to","subject"],"properties":{"from":{"type":"string"},"to":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"cc":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"bcc":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"subject":{"type":"string"},"html":{"type":"string"},"text":{"type":"string"},"reply_to":{"type":"string"},"headers":{"type":"object","additionalProperties":{"type":"string"}},"attachments":{"type":"array","items":{"type":"object","properties":{"filename":{"type":"string"},"content":{"type":"string","description":"base64"},"path":{"type":"string"},"content_type":{"type":"string"}}}},"tags":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"value":{"type":"string"}}}},"scheduled_at":{"type":"string","format":"date-time"},"x_region":{"type":"string"},"x_brand_id":{"type":"string"}}},"Email":{"type":"object","properties":{"id":{"type":"string"},"to":{"type":"string"},"from":{"type":"string"},"subject":{"type":["string","null"]},"status":{"type":"string"},"last_event":{"type":"string"},"mode":{"type":"string"},"scheduled_at":{"type":["string","null"]},"created_at":{"type":"string"},"provider":{"type":["string","null"]},"region":{"type":["string","null"]},"error":{"type":["string","null"]}}},"Domain":{"type":"object","properties":{"id":{"type":"string"},"domain":{"type":"string"},"brand_id":{"type":["string","null"]},"provider":{"type":"string"},"status":{"type":"string"},"ses_region":{"type":["string","null"]},"dns_records":{"type":"array","items":{"type":"object"}},"verified_at":{"type":["string","null"]},"created_at":{"type":"string"}}},"Contact":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"first_name":{"type":["string","null"]},"last_name":{"type":["string","null"]},"status":{"type":"string","enum":["active","unsubscribed","bounced","complained"]},"source":{"type":["string","null"]},"created_at":{"type":"string"}}},"Suppression":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"reason":{"type":["string","null"]},"source":{"type":["string","null"]},"created_at":{"type":"string"}}},"BroadcastRequest":{"type":"object","required":["from","subject"],"properties":{"from":{"type":"string"},"subject":{"type":"string"},"html":{"type":"string"},"text":{"type":"string"},"reply_to":{"type":"string"},"brand_id":{"type":"string"}}},"BroadcastPreview":{"type":"object","properties":{"object":{"const":"broadcast_preview"},"mode":{"type":"string"},"brand":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]}}},"from":{"type":"string"},"subject":{"type":"string"},"recipients":{"type":"integer"},"total_active_contacts":{"type":"integer"},"suppressed":{"type":"integer"},"will_send":{"type":"integer"},"warmup_capped":{"type":"integer"},"quota":{"type":"object","properties":{"used":{"type":"integer"},"limit":{"type":["integer","null"]},"remaining":{"type":["integer","null"]},"remaining_after_send":{"type":["integer","null"]},"allowed":{"type":"boolean"}}},"sendable":{"type":"boolean"},"blocked_reason":{"type":["string","null"]},"confirm_token":{"type":["string","null"]},"confirm_expires_at":{"type":["string","null"]}}},"Webhook":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"enabled":{"type":"boolean"},"created_at":{"type":"string"}}},"Deleted":{"type":"object","properties":{"deleted":{"const":true},"id":{"type":"string"}}}}}}