models.py•23.7 kB
# generated by fastapi-codegen:
# filename: openapi.yaml
# timestamp: 2025-07-07T16:18:59+00:00
from __future__ import annotations
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field, RootModel
class ApiKey(BaseModel):
created_at: Optional[datetime] = Field(
None, description='The date and time the API key was created.'
)
id: Optional[str] = Field(None, description='The ID of the API key.')
name: Optional[str] = Field(None, description='The name of the API key.')
class Attachment(BaseModel):
content: Optional[bytes] = Field(None, description='Content of an attached file.')
content_type: Optional[str] = Field(
None,
description='Optional content type for the attachment, if not set it will be derived from the filename property',
)
filename: Optional[str] = Field(None, description='Name of attached file.')
path: Optional[str] = Field(
None, description='Path where the attachment file is hosted'
)
class Permission(Enum):
full_access = 'full_access'
sending_access = 'sending_access'
class CreateApiKeyRequest(BaseModel):
domain_id: Optional[str] = Field(
None,
description='Restrict an API key to send emails only from a specific domain. Only used when the permission is sending_acces.',
)
name: str = Field(..., description='The API key name.')
permission: Optional[Permission] = Field(
None,
description='The API key can have full access to Resend’s API or be only restricted to send emails. * full_access - Can create, delete, get, and update any resource. * sending_access - Can only send emails.',
)
class CreateApiKeyResponse(BaseModel):
id: Optional[str] = Field(None, description='The ID of the API key.')
token: Optional[str] = Field(None, description='The token of the API key.')
class CreateAudienceOptions(BaseModel):
name: str = Field(..., description='The name of the audience you want to create.')
class CreateAudienceResponseSuccess(BaseModel):
id: Optional[str] = Field(
None,
description='The ID of the audience.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
name: Optional[str] = Field(
None, description='The name of the audience.', examples=['Registered Users']
)
object: Optional[str] = Field(
None, description='The object of the audience.', examples=['audience']
)
class Datum(BaseModel):
id: Optional[str] = Field(None, description='The ID of the sent email.')
class CreateBatchEmailsResponse(BaseModel):
data: Optional[List[Datum]] = None
class CreateBroadcastOptions(BaseModel):
audience_id: str = Field(
...,
description='Unique identifier of the audience this broadcast will be sent to.',
)
from_: str = Field(
..., alias='from', description='The email address of the sender.'
)
html: Optional[str] = Field(None, description='The HTML version of the message.')
name: Optional[str] = Field(None, description='Name of the broadcast.')
preview_text: Optional[str] = Field(
None,
description='The preview text of the email.',
examples=['Here are our announcements'],
)
reply_to: Optional[List[str]] = Field(
None, description='The email addresses to which replies should be sent.'
)
subject: str = Field(..., description='The subject line of the email.')
text: Optional[str] = Field(
None, description='The plain text version of the message.'
)
class CreateBroadcastResponseSuccess(BaseModel):
id: Optional[str] = Field(
None,
description='The ID of the broadcast.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
object: Optional[str] = Field(
None, description='The object type of the response.', examples=['broadcast']
)
class CreateContactOptions(BaseModel):
audience_id: Optional[str] = Field(
None,
description='Unique identifier of the audience to which the contact belongs.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
email: str = Field(
...,
description='Email address of the contact.',
examples=['steve.wozniak@gmail.com'],
)
first_name: Optional[str] = Field(
None, description='First name of the contact.', examples=['Steve']
)
last_name: Optional[str] = Field(
None, description='Last name of the contact.', examples=['Wozniak']
)
unsubscribed: Optional[bool] = Field(
None, description='Indicates if the contact is unsubscribed.', examples=[False]
)
class CreateContactResponseSuccess(BaseModel):
id: Optional[str] = Field(
None,
description='Unique identifier for the created contact.',
examples=['479e3145-dd38-476b-932c-529ceb705947'],
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['contact']
)
class Region(Enum):
us_east_1 = 'us-east-1'
eu_west_1 = 'eu-west-1'
sa_east_1 = 'sa-east-1'
class CreateDomainRequest(BaseModel):
name: str = Field(..., description='The name of the domain you want to create.')
region: Optional[Region] = Field(
'us-east-1',
description="The region where emails will be sent from. Possible values are us-east-1' | 'eu-west-1' | 'sa-east-1",
)
class DeleteDomainResponse(BaseModel):
deleted: Optional[bool] = Field(
None,
description='Indicates whether the domain was deleted successfully.',
examples=[True],
)
id: Optional[str] = Field(
None,
description='The ID of the domain.',
examples=['d91cd9bd-1176-453e-8fc1-35364d380206'],
)
object: Optional[str] = Field(
None, description='The type of object.', examples=['domain']
)
class DomainRecord(BaseModel):
name: Optional[str] = Field(None, description='The name of the record.')
priority: Optional[int] = Field(None, description='The priority of the record.')
record: Optional[str] = Field(None, description='The type of record.')
status: Optional[str] = Field(None, description='The status of the record.')
ttl: Optional[str] = Field(None, description='The time to live for the record.')
type: Optional[str] = Field(None, description='The type of record.')
value: Optional[str] = Field(None, description='The value of the record.')
class Email(BaseModel):
bcc: Optional[List[str]] = Field(
None, description='The email addresses of the blind carbon copy recipients.'
)
cc: Optional[List[str]] = Field(
None, description='The email addresses of the carbon copy recipients.'
)
created_at: Optional[datetime] = Field(
None,
description='The date and time the email was created.',
examples=['2023-04-03T22:13:42.674981+00:00'],
)
from_: Optional[str] = Field(
None,
alias='from',
description='The email address of the sender.',
examples=['Acme <onboarding@resend.dev>'],
)
html: Optional[str] = Field(
None,
description='The HTML body of the email.',
examples=['Congrats on sending your <strong>first email</strong>!'],
)
id: Optional[str] = Field(
None,
description='The ID of the email.',
examples=['4ef9a417-02e9-4d39-ad75-9611e0fcc33c'],
)
last_event: Optional[str] = Field(
None, description='The status of the email.', examples=['delivered']
)
object: Optional[str] = Field(
None, description='The type of object.', examples=['email']
)
reply_to: Optional[List[str]] = Field(
None, description='The email addresses to which replies should be sent.'
)
subject: Optional[str] = Field(
None, description='The subject line of the email.', examples=['Hello World']
)
text: Optional[str] = Field(None, description='The plain text body of the email.')
to: Optional[List[str]] = Field(None, examples=[['delivered@resend.dev']])
class GetAudienceResponseSuccess(BaseModel):
created_at: Optional[str] = Field(
None,
description='The date that the object was created.',
examples=['2023-10-06 22:59:55.977000+00:00'],
)
id: Optional[str] = Field(
None,
description='The ID of the audience.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
name: Optional[str] = Field(
None, description='The name of the audience.', examples=['Registered Users']
)
object: Optional[str] = Field(
None, description='The object of the audience.', examples=['audience']
)
class GetBroadcastResponseSuccess(BaseModel):
audience_id: Optional[str] = Field(
None,
description='Unique identifier of the audience this broadcast will be sent to.',
)
created_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the broadcast was created.',
examples=['2023-10-06T22:59:55.977Z'],
)
from_: Optional[str] = Field(
None,
alias='from',
description='The email address of the sender.',
examples=['Acme <onboarding@resend.dev>'],
)
id: Optional[str] = Field(
None,
description='Unique identifier for the broadcast.',
examples=['e169aa45-1ecf-4183-9955-b1499d5701d3'],
)
name: Optional[str] = Field(
None, description='Name of the broadcast.', examples=['November announcements']
)
preview_text: Optional[str] = Field(
None,
description='The preview text of the email.',
examples=['Here are our announcements'],
)
reply_to: Optional[List[str]] = Field(
None, description='The email addresses to which replies should be sent.'
)
scheduled_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the broadcast is scheduled to be sent.',
examples=['2023-10-06T22:59:55.977Z'],
)
sent_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the broadcast was sent.',
examples=['2023-10-06T22:59:55.977Z'],
)
status: Optional[str] = Field(
None, description='The status of the broadcast.', examples=['draft']
)
subject: Optional[str] = Field(
None, description='The subject line of the email.', examples=['Hello World']
)
class GetContactResponseSuccess(BaseModel):
created_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the contact was created.',
examples=['2023-10-06T23:47:56.678Z'],
)
email: Optional[str] = Field(
None,
description='Email address of the contact.',
examples=['steve.wozniak@gmail.com'],
)
first_name: Optional[str] = Field(
None, description='First name of the contact.', examples=['Steve']
)
id: Optional[str] = Field(
None,
description='Unique identifier for the contact.',
examples=['e169aa45-1ecf-4183-9955-b1499d5701d3'],
)
last_name: Optional[str] = Field(
None, description='Last name of the contact.', examples=['Wozniak']
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['contact']
)
unsubscribed: Optional[bool] = Field(
None, description='Indicates if the contact is unsubscribed.', examples=[False]
)
class ListApiKeysResponse(BaseModel):
data: Optional[List[ApiKey]] = None
class Datum1(BaseModel):
created_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the audience was created.',
examples=['2023-10-06T22:59:55.977Z'],
)
id: Optional[str] = Field(
None,
description='Unique identifier for the audience.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
name: Optional[str] = Field(
None, description='Name of the audience.', examples=['Registered Users']
)
class ListAudiencesResponseSuccess(BaseModel):
data: Optional[List[Datum1]] = Field(
None, description='Array containing audience information.'
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['list']
)
class Datum2(BaseModel):
audience_id: Optional[str] = Field(
None,
description='Unique identifier of the audience this broadcast will be sent to.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
created_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the broadcast was created.',
examples=['2023-10-06T22:59:55.977Z'],
)
id: Optional[str] = Field(
None,
description='Unique identifier for the broadcast.',
examples=['e169aa45-1ecf-4183-9955-b1499d5701d3'],
)
name: Optional[str] = Field(
None, description='Name of the broadcast.', examples=['November announcements']
)
scheduled_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the broadcast is scheduled to be sent.',
examples=['2023-10-06T22:59:55.977Z'],
)
sent_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the broadcast was sent.',
examples=['2023-10-06T22:59:55.977Z'],
)
status: Optional[str] = Field(
None, description='The status of the broadcast.', examples=['draft']
)
class ListBroadcastsResponseSuccess(BaseModel):
data: Optional[List[Datum2]] = Field(
None, description='Array containing broadcast information.'
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['list']
)
class Datum3(BaseModel):
created_at: Optional[datetime] = Field(
None,
description='Timestamp indicating when the contact was created.',
examples=['2023-10-06T23:47:56.678Z'],
)
email: Optional[str] = Field(
None,
description='Email address of the contact.',
examples=['steve.wozniak@gmail.com'],
)
first_name: Optional[str] = Field(
None, description='First name of the contact.', examples=['Steve']
)
id: Optional[str] = Field(
None,
description='Unique identifier for the contact.',
examples=['e169aa45-1ecf-4183-9955-b1499d5701d3'],
)
last_name: Optional[str] = Field(
None, description='Last name of the contact.', examples=['Wozniak']
)
unsubscribed: Optional[bool] = Field(
None, description='Indicates if the contact is unsubscribed.', examples=[False]
)
class ListContactsResponseSuccess(BaseModel):
data: Optional[List[Datum3]] = Field(
None, description='Array containing contact information.'
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['list']
)
class ListDomainsItem(BaseModel):
created_at: Optional[datetime] = Field(
None,
description='The date and time the domain was created.',
examples=['2023-04-26T20:21:26.347412+00:00'],
)
id: Optional[str] = Field(
None,
description='The ID of the domain.',
examples=['d91cd9bd-1176-453e-8fc1-35364d380206'],
)
name: Optional[str] = Field(
None, description='The name of the domain.', examples=['example.com']
)
region: Optional[str] = Field(
None,
description='The region where the domain is hosted.',
examples=['us-east-1'],
)
status: Optional[str] = Field(
None, description='The status of the domain.', examples=['not_started']
)
class ListDomainsResponse(BaseModel):
data: Optional[List[ListDomainsItem]] = None
class RemoveAudienceResponseSuccess(BaseModel):
deleted: Optional[bool] = Field(
None,
description='The deleted attribute indicates that the corresponding audience has been deleted.',
examples=[True],
)
id: Optional[str] = Field(
None,
description='The ID of the audience.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
object: Optional[str] = Field(
None, description='The object of the audience.', examples=['audience']
)
class RemoveBroadcastResponseSuccess(BaseModel):
deleted: Optional[bool] = Field(
None,
description='The deleted attribute indicates that the corresponding broadcast has been deleted.',
examples=[True],
)
id: Optional[str] = Field(
None,
description='The ID of the broadcast.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['broadcast']
)
class RemoveContactResponseSuccess(BaseModel):
deleted: Optional[bool] = Field(
None,
description='Indicates whether the contact was successfully deleted.',
examples=[True],
)
id: Optional[str] = Field(
None,
description='Unique identifier for the removed contact.',
examples=['520784e2-887d-4c25-b53c-4ad46ad38100'],
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['contact']
)
class SendBroadcastOptions(BaseModel):
scheduled_at: Optional[str] = Field(
None,
description='Schedule email to be sent later. The date should be in ISO 8601 format.',
)
class SendBroadcastResponseSuccess(BaseModel):
id: Optional[str] = Field(
None,
description='The ID of the broadcast.',
examples=['78261eea-8f8b-4381-83c6-79fa7120f1cf'],
)
class SendEmailResponse(BaseModel):
id: Optional[str] = Field(None, description='The ID of the sent email.')
class Tag(BaseModel):
name: Optional[str] = Field(
None,
description='The name of the email tag. It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.',
)
value: Optional[str] = Field(
None,
description='The value of the email tag.It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-). It can contain no more than 256 characters.',
)
class UpdateContactOptions(BaseModel):
email: Optional[str] = Field(
None,
description='Email address of the contact.',
examples=['steve.wozniak@gmail.com'],
)
first_name: Optional[str] = Field(
None, description='First name of the contact.', examples=['Steve']
)
last_name: Optional[str] = Field(
None, description='Last name of the contact.', examples=['Wozniak']
)
unsubscribed: Optional[bool] = Field(
None,
description='Indicates the subscription status of the contact.',
examples=[False],
)
class UpdateContactResponseSuccess(BaseModel):
id: Optional[str] = Field(
None,
description='Unique identifier for the updated contact.',
examples=['479e3145-dd38-476b-932c-529ceb705947'],
)
object: Optional[str] = Field(
None, description='Type of the response object.', examples=['contact']
)
class UpdateDomainOptions(BaseModel):
click_tracking: Optional[bool] = Field(
None, description='Track clicks within the body of each HTML email.'
)
open_tracking: Optional[bool] = Field(
None, description='Track the open rate of each email.'
)
tls: Optional[str] = Field('opportunistic', description='enforced | opportunistic.')
class UpdateDomainResponseSuccess(BaseModel):
id: Optional[str] = Field(
None,
description='The ID of the updated domain.',
examples=['d91cd9bd-1176-453e-8fc1-35364d380206'],
)
object: Optional[str] = Field(
None,
description='The object type representing the updated domain.',
examples=['domain'],
)
class UpdateEmailOptions(BaseModel):
scheduled_at: Optional[str] = Field(
None,
description='Schedule email to be sent later. The date should be in ISO 8601 format.',
)
class VerifyDomainResponse(BaseModel):
id: Optional[str] = Field(
None,
description='The ID of the domain.',
examples=['d91cd9bd-1176-453e-8fc1-35364d380206'],
)
object: Optional[str] = Field(
None, description='The type of object.', examples=['domain']
)
class CreateDomainResponse(BaseModel):
created_at: Optional[datetime] = Field(
None, description='The date and time the domain was created.'
)
id: Optional[str] = Field(None, description='The ID of the domain.')
name: Optional[str] = Field(None, description='The name of the domain.')
records: Optional[List[DomainRecord]] = None
region: Optional[str] = Field(
None, description='The region where the domain is hosted.'
)
status: Optional[str] = Field(None, description='The status of the domain.')
class Domain(BaseModel):
created_at: Optional[datetime] = Field(
None,
description='The date and time the domain was created.',
examples=['2023-04-26T20:21:26.347412+00:00'],
)
id: Optional[str] = Field(
None,
description='The ID of the domain.',
examples=['d91cd9bd-1176-453e-8fc1-35364d380206'],
)
name: Optional[str] = Field(
None, description='The name of the domain.', examples=['example.com']
)
object: Optional[str] = Field(
None, description='The type of object.', examples=['domain']
)
records: Optional[List[DomainRecord]] = None
region: Optional[str] = Field(
None,
description='The region where the domain is hosted.',
examples=['us-east-1'],
)
status: Optional[str] = Field(
None, description='The status of the domain.', examples=['not_started']
)
class SendEmailRequest(BaseModel):
attachments: Optional[List[Attachment]] = None
bcc: Optional[str] = Field(
None,
description='Bcc recipient email address. For multiple addresses, send as an array of strings.',
)
cc: Optional[str] = Field(
None,
description='Cc recipient email address. For multiple addresses, send as an array of strings.',
)
from_: str = Field(
...,
alias='from',
description='Sender email address. To include a friendly name, use the format "Your Name <sender@domain.com>".',
)
headers: Optional[Dict[str, Any]] = Field(
None, description='Custom headers to add to the email.'
)
html: Optional[str] = Field(None, description='The HTML version of the message.')
reply_to: Optional[str] = Field(
None,
description='Reply-to email address. For multiple addresses, send as an array of strings.',
)
scheduled_at: Optional[str] = Field(
None,
description='Schedule email to be sent later. The date should be in ISO 8601 format.',
)
subject: str = Field(..., description='Email subject.')
tags: Optional[List[Tag]] = None
text: Optional[str] = Field(
None, description='The plain text version of the message.'
)
to: List[str]
class EmailsBatchPostRequest(RootModel[List[SendEmailRequest]]):
root: List[SendEmailRequest]