Skip to main content

Create Contact

Create a new contact in your easymail account.

Request

POST /contacts

Request Body

ParameterTypeRequiredDescription
emailstringYesContact's email address (must be valid email format)
first_namestringNoContact's first name (max 255 characters)
last_namestringNoContact's last name (max 255 characters)
phonestringNoContact's phone number (max 32 characters)
external_idstringNoExternal identifier for integration purposes (max 255 characters)
languagestringNoISO 639-1 language code (2 characters, e.g., "en", "pl")
country_codestringNoISO 3166-1 alpha-2 country code (2 characters, e.g., "US", "PL")
contact_listsarray of stringsNoUUIDs of contact lists the new contact should be subscribed to
note

When contact_lists is provided, all list UUIDs must belong to your account - otherwise the request is rejected and no contact is created. Any list from which the contact (matched by email) was previously unsubscribed is silently skipped; the contact will still be created and added to the remaining lists.

Example Request

curl -X POST "https://email.easy.tools/api/v1/contacts" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"email": "john@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+48123456789",
"external_id": "customer_123",
"language": "en",
"country_code": "US",
"contact_lists": [
"9f3c2a1e-8b7d-4e2f-a1c6-2d4f5e6a7b8c",
"7a1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d"
]
}'

Response

Success Response (201 Created)

{
"data": {
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"email": "john@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+48123456789",
"external_id": "customer_123",
"language": "en",
"country_code": "US",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T10:30:00Z"
}
}

Response Fields

FieldTypeDescription
uuidstringUnique identifier for the contact
emailstringContact's email address
first_namestring|nullContact's first name
last_namestring|nullContact's last name
phonestring|nullContact's phone number
external_idstring|nullExternal identifier for integration purposes
languagestring|nullISO 639-1 language code
country_codestring|nullISO 3166-1 alpha-2 country code
created_atstringISO 8601 timestamp (UTC)
updated_atstringISO 8601 timestamp (UTC)

Error Responses

Duplicate Email Error (409 Conflict)

Returned when a contact with the same email already exists.

{
"error": {
"code": "DUPLICATE_RESOURCE",
"message": "Contact with email 'john@example.com' already exists"
}
}

Not Found Error (404) - Contact Lists

Returned when one or more UUIDs passed in contact_lists do not exist for your account. The contact is not created in this case.

{
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "Contact lists not found: 9f3c2a1e-8b7d-4e2f-a1c6-2d4f5e6a7b8c"
}
}

Validation Error (422 Unprocessable Entity)

{
"error": {
"code": "VALIDATION_ERROR",
"message": "The given data was invalid",
"details": {
"email": ["The email field is required."],
"language": ["The language must be 2 characters."],
"contact_lists.0": ["The contact_lists.0 must be a valid UUID."]
}
}
}