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). Must be unique within your account
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")
timezone_uuidstring|nullNoUUID of the timezone to assign to the contact, from List Timezones. Send null to leave it unset. An unknown UUID returns 404. Read it back with Get Contact.
contact_listsarray of stringsNoUUIDs of contact lists the new contact should be subscribed to
custom_fieldsarrayNoCustom field values to set on the new contact (see Custom Fields section below)

When contact_lists is provided, every list UUID must belong to your account — otherwise the request is rejected and no contact is created.

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"
]
}'

Custom Fields

Set custom field values on the new contact by including the custom_fields array. Each field_key must reference a custom field that already exists in your account; unknown keys are rejected with 422 and no contact is created.

Custom Field Object

FieldTypeRequiredDescription
field_keystringYesThe unique key of the custom field
valuemixedYes (key must be present)The value to set (type depends on the field type). The value key must be present on each entry, but it may be null or "", which sets no value for that field.

Supported Field Types and Value Formats

Field TypeExpected ValueExample
textstring or numeric (max 255 characters)"Acme Inc", 123
numbernumeric42, 3.14, "100"
booleanbool, or string/int representationtrue, false, "yes", "no", 1, 0
datedate string"2025-01-15", "15/01/2025", "01-15-2025"
datetimedatetime string"2025-01-15T10:30:00", "2025-01-15 10:30:00", "2025-01-15T10:30"
selectstring (must match a predefined option)"enterprise"
listarray of strings (max 100 elements, each ≤255 chars)["Webinar X", "Webinar Y"]

Supported Date Formats

A date value accepts any of these:

  • Y-m-d (e.g. "2025-01-15"), and the same date with a time component: Y-m-d\TH:i:s, Y-m-d\TH:i:sP, Y-m-d H:i:s
  • European: d/m/Y, d-m-Y, d.m.Y (each with an optional H:i:s time)
  • US: m/d/Y, m-d-Y (each with an optional H:i:s time)

Only the date part is stored; any time component is discarded.

Supported DateTime Formats

A datetime value accepts only these, and must match one of them exactly (no timezone offset or trailing Z):

  • Y-m-d\TH:i:s (e.g. "2025-01-15T10:30:00")
  • Y-m-d H:i:s (e.g. "2025-01-15 10:30:00")
  • Y-m-d\TH:i (e.g. "2025-01-15T10:30")
  • Y-m-d H:i (e.g. "2025-01-15 10:30")

Example Request with Custom Fields

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",
"custom_fields": [
{"field_key": "company", "value": "Acme Inc"},
{"field_key": "plan", "value": "enterprise"},
{"field_key": "is_vip", "value": true},
{"field_key": "signup_date", "value": "2025-01-15"},
{"field_key": "events-attended", "value": ["Webinar X", "Webinar Y"]}
]
}'

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",
"lists": [
{
"uuid": "9f3c2a1e-8b7d-4e2f-a1c6-2d4f5e6a7b8c",
"name": "Newsletter"
}
],
"custom_fields": [
{
"field_key": "company",
"value": "Acme Inc"
}
],
"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
listsarrayContact lists the contact is subscribed to. Each entry has uuid and name.
custom_fieldsarrayCustom field values set on the contact. Each entry has field_key and value.
created_atstringISO 8601 timestamp (UTC)
updated_atstringISO 8601 timestamp (UTC)

Error Responses

Duplicate Contact Error (409 Conflict)

Returned when a contact with the same email already exists, or when the external_id you sent is already used by another contact. Each email and each external_id must be unique within your account. No contact is created in this case.

{
"error": {
"code": "DUPLICATE_RESOURCE",
"message": "Contact with email 'john@example.com' already exists"
}
}
{
"error": {
"code": "DUPLICATE_RESOURCE",
"message": "Contact with external id 'customer_123' 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"
}
}

Not Found Error (404) - Timezone

Returned when timezone_uuid does not match a timezone from List Timezones. The contact is not created in this case.

{
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "Timezone not found"
}
}

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 field must be 2 characters."],
"contact_lists.0": ["The contact_lists.0 field must be a valid UUID."]
}
}
}

Custom Field Validation Error (422 Unprocessable Entity)

Returned when a value in custom_fields cannot be applied — for example an unknown field_key, a select value outside the field's options, a value of the wrong type, a text value over 255 characters, or a field that is set automatically and cannot be modified. No contact is created in this case. The specific reason is in details.custom_fields.

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Custom field validation failed",
"details": {
"custom_fields": ["Custom field 'plan' value 'invalid_option' is not a valid option. Allowed options: free, pro, enterprise"]
}
}
}