Console API
The Console API provides a way to interact with the features of the Console programmatically. It is also used to send emails.
To get started, create an API key from the Console. Note that the API key is project-specific, meaning it can only be used with the project it was created in.
API Usage
- API URL:
https://relay.hyvor.com/api/console - Content-Type:
application/json(both for requests and responses) - Authentication: Set the
Authorizationheader with your API key as a Bearer token:Authorization: Bearer <your_api_key>
Scopes
Scopes are used to control access to endpoints of the Console API. When creating an API key, you can select the scopes that the key will have access to. The available scopes are:
- sends.read
- sends.send
- domains.read
- domains.write
- webhooks.read
- webhooks.write
- api_keys.read
- api_keys.write
- suppressions.read
- suppressions.write
- analytics.read
- org.projects.create
Each endpoint requires specific scopes to be included in the API key.
Rate Limiting
The Console API has rate limits to prevent abuse and ensure fair usage.
- Default rate limit: 100 requests per minute (per API key)
- Email sending rate limit: 10 requests per second (per project)
If you exceed these limits, you will receive a 429 Too Many Requests response. The following standard headers are included in all API
responses to indicate the current rate limit status:
X-RateLimit-Limit: The maximum number of requests allowed in the current time window.X-RateLimit-Remaining: The number of requests remaining in the current time window.X-RateLimit-Reset: How many seconds until the rate limit resets.
Errors
When a request fails, the Console API responds with a non-2xx HTTP status code and a JSON body describing the error:
type ErrorResponse = {
message: string, // human-readable error message
status: number, // matches the HTTP response status code
violations?: { property: string, message: string }[] // present on 422 validation errors
}Examples:
// 401 Unauthorized
{ message: "Invalid API key.", status: 401 }
// 403 Forbidden
{ message: "Client IP is not allowed for this API key.", status: 403 }
// 404 Not Found
{ message: "Domain not found", status: 404 }
// 422 Unprocessable Entity
{
message: "domain: This value is not a valid domain.",
status: 422,
violations: [
{ property: "domain", message: "This value is not a valid domain." }
]
}
// 429 Too Many Requests
{ message: "Rate limit exceeded. Please try again later in 42 seconds.", status: 429 }
// 500 Internal Server Error
{ message: "Internal Server Error. Our team has been notified.", status: 500 }See Rate Limiting for more about 429 Too Many Requests responses.
Endpoints
Projects
Endpoints:
- POST /projects - Create a new project
Create Project
POST /projects (scope: org.projects.create)
type Request = {
name: string,
send_type: 'transactional' | 'distributional'
}
type Response = ProjectUserSends (Emails)
Endpoints:
- POST /sends - Send an email
- GET /sends - Get sends
- GET /sends/:id - Get a send by ID
- GET /sends/uuid/:uuid - Get a send by UUID
- POST /sends/:id/retry - Retry a failed send
Objects:
Send Email
POST /sends (scope: sends.send)
Visit the Send Emails page for a detailed guide on how to send emails using this endpoint.
type Address = string | { email: string, name?: string };
type Request = {
from: Address,
to: Address | Address[],
cc?: Address | Address[],
bcc?: Address | Address[],
subject?: string,
body_html?: string,
body_text?: string,
headers?: Record<string, string>,
attachments?: Array<{
content: string, // base64 encoded
name?: string,
content_type?: string
}>
}
type Response = {
id: number,
message_id: string
}Get Sends
GET /sends (scope: sends.read)
type Request = {
limit?: number, // Optional. Default is 50
before_id?: number, // Optional. For pagination: pass the id of the last send in the current list
status?: 'queued' | 'processing' | 'accepted' | 'bounced' | 'complained', // Optional. Filter by status
from_search?: string, // Optional. Search from address
to_search?: string // Optional. Search to address
}
type Response = Send[]Get Send by ID
GET /sends/:id (scope: sends.read)
type Request = {}
type Response = Send // includes attempts arrayGet Send by UUID
GET /sends/uuid/:uuid (scope: sends.read)
type Request = {}
type Response = Send // includes attempts arrayRetry Send
POST /sends/:id/retry (scope: sends.send)
Re-queues failed recipients of a send for retry. The send must not already be queued. Only
recipients with a failed status will be retried.
type Request = {
send_after?: number // Optional unix timestamp. Defaults to now.
}
type Response = {
retried_recipients: number // Count of re-queued recipients
}Domains
Endpoints:
- GET /domains - Get domains of the project
- POST /domains - Create a new domain for the project
- POST /domains/verify - Verify a domain
- GET /domains/:id - Get a domain by ID or domain name
- DELETE /domains - Delete a domain by ID or domain name
Objects:
Get Domains
GET /domains (scope: domains.read)
type Request = {
limit?: number, // Optional. Default is 50
offset?: number, // Optional. Default is 0
search?: string, // Optional. Search by domain name
}
type Response = Domain[]Create Domain
POST /domains (scope: domains.write)
type Request = {
// domain to add
// unique within the project
domain: string
// optional custom DKIM selector.
// auto-generated if not provided.
dkim_selector?: string
// optional custom RSA private key (PEM format).
// min bits: 1024
// auto-generated if not provided.
dkim_private_key?: string
}
type Response = DomainIf you set a custom dkim_selector, consider this: one domain can only have one TXT
record per selector in DNS. To avoid first come first serve problem, Hyvor Relay does not check
for the global uniqueness of the selector; it is your responsibility. If you are a platform
provider, it is recommended to use a unique prefix (e.g. myplatform-) or a
timestamp to minimize the risk of conflicts.
Verify Domain
POST /domains/verify (scope: domains.write)
type Request = {
// Either id or domain must be provided
id?: number,
domain?: string
}
type Response = DomainGet Domain
GET /domains/by (scope: domains.read)
type Request = {
// Either id or domain must be provided
id?: number,
domain?: string
}
type Response = Domain type Request = {}
type Response = DomainDelete Domain
DELETE /domains (scope: domains.write)
type Request = {
// Either id or domain must be provided
id?: number,
domain?: string
}
type Response = {}Webhooks
Endpoints:
- GET /webhooks - Get webhooks for the project
- POST /webhooks - Create a new webhook
- PATCH /webhooks/:id - Update a webhook
- DELETE /webhooks/:id - Delete a webhook
- GET /webhooks/deliveries - Get webhook deliveries
Objects:
Get Webhooks
GET /webhooks
type Request = {}
type Response = Webhook[]Create Webhook
POST /webhooks
See Webhooks page for available events.
type Request = {
url: string,
description: string,
events: string[]
}
type Response = WebhookUpdate Webhook
PATCH /webhooks/:id
type Request = {
url: string,
description: string,
events: string[]
}
type Response = WebhookDelete Webhook
DELETE /webhooks/:id
type Request = {}
type Response = {}Get Webhook Deliveries
GET /webhooks/deliveries
type Request = {
webhook_id?: number // Optional. Filter by webhook ID
}
type Response = WebhookDelivery[]API Keys
Endpoints:
- GET /api-keys - Get API keys for the project
- POST /api-keys - Create a new API key
- PATCH /api-keys/:id - Update an API key
- DELETE /api-keys/:id - Delete an API key
Objects:
Get API Keys
GET /api-keys (scope: api_keys.read)
type Request = {}
type Response = ApiKey[]Create API Key
POST /api-keys (scope: api_keys.write)
Note: Maximum of 10 API keys are allowed per project.
type Request = {
name: string,
scopes: string[]
}
type Response = ApiKey // includes the raw key only on creationUpdate API Key
PATCH /api-keys/:id (scope: api_keys.write)
type Request = {
name?: string,
is_enabled?: boolean,
scopes?: string[]
}
type Response = ApiKeyDelete API Key
DELETE /api-keys/:id (scope: api_keys.write)
type Request = {}
type Response = {}Suppressions
Endpoints:
- GET /suppressions - Get suppressions for the project
- DELETE /suppressions/:id - Delete a suppression
Objects:
Get Suppressions
GET /suppressions (scope: suppressions.read)
type Request = {
email?: string, // Optional. Search by email
reason?: 'bounce' | 'complaint' // Optional. Filter by reason
}
type Response = Suppression[]Delete Suppression
DELETE /suppressions/:id (scope: suppressions.write)
type Request = {}
type Response = {}Analytics
Endpoints:
- GET /analytics/stats - Get analytics statistics
- GET /analytics/sends/chart - Get sends chart data
Get Analytics Statistics
GET /analytics/stats (scope: analytics.read)
type Request = {
period?: '30d' | '7d' | '24h' // Optional. Default is '30d'
}
type Response = {
sends: number,
bounce_rate: number,
complaint_rate: number
}Get Analytics Chart Data
GET /analytics/sends/chart (scope: analytics.read)
type Request = {}
type Response = any // Chart data formatObjects
Send Object
interface Send {
id: number;
uuid: string;
created_at: number;
from_address: string;
from_name: string | null;
subject: string | null;
body_html: string | null;
body_text: string | null;
headers: Record<string, string>;
raw: string;
queued: boolean;
send_after: number;
recipients: SendRecipient[];
attempts: SendAttempt[];
feedback: SendFeedback[];
}
SendRecipient Object
interface SendRecipient {
id: number;
type: 'to' | 'cc' | 'bcc';
address: string;
name: string;
status: 'queued' | 'accepted' | 'deferred' | 'bounced' | 'complained' | 'suppressed' | 'failed';
try_count: number;
}
SendAttempt Object
interface SendAttempt {
id: number;
created_at: number;
status: 'accepted' | 'deferred' | 'bounced' | 'failed';
try_count: number;
resolved_mx_hosts: string[];
responded_mx_host: string | null;
smtp_conversations: Record<string, any>;
recipients: SendAttemptRecipient[];
duration_ms: number;
error: string | null;
}
SendAttemptRecipient Object
interface SendAttemptRecipient {
id: number;
created_at: number;
recipient_id: number;
status: 'accepted' | 'deferred' | 'bounced' | 'failed';
smtp_code: number;
smtp_enhanced_code: string | null;
smtp_message: string;
is_suppressed: boolean;
}SendFeedback Object
interface SendFeedback {
id: number;
created_at: number;
type: 'bounce' | 'complaint';
recipient_id: number;
debug_incoming_email_id: number;
bounce_reason: 'recipient' | 'infrastructure' | 'unknown' | null;
}Bounce Object
interface Bounce {
text: string;
status: string;
}
Complaint Object
interface Complaint {
text: string;
feedback_type: string;
}
Domain Object
interface Domain {
id: number;
created_at: number;
domain: string;
status: 'pending' | 'active' | 'warning' | 'suspended';
dkim_selector: string;
dkim_host: string;
dkim_public_key: string;
dkim_txt_value: string;
dkim_checked_at: number | null;
dkim_error_message: string | null;
}
More about Domain Status.
Webhook Object
interface Webhook {
id: number;
url: string;
description: string | null;
events: string[];
secret: string | null;
}
WebhookDelivery Object
interface WebhookDelivery {
id: number;
created_at: number;
url: string;
event: string;
status: 'pending' | 'delivered' | 'failed';
response: string | null;
}
ApiKey Object
interface ApiKey {
id: number;
name: string;
scopes: string[];
key: string | null; // Only included when creating a new key
created_at: number;
is_enabled: boolean;
last_accessed_at: number | null;
}
Suppression Object
interface Suppression {
id: number;
created_at: number;
email: string;
reason: 'bounce' | 'complaint';
description: string | null;
}