POST /api/v1/profile/custom-event/save/

Save custom event

Records a custom event for a profile: something that happens in your app, such as a completed onboarding. To start email sequences with the event, add its name to the entry rule of a purpose. To stop sequences early with the event, add its name to the exit rule of a purpose.

Add the name before you send the event. Purpose rules only apply to events that Adapty Mail receives after you add the name.

Request body

event_typestringrequired

The event name, such as onboarding_completed. It has up to 64 characters: lowercase letters, digits, and underscores, with a letter first. Use the same name as under Custom in the entry rule or exit rule of a purpose. You can't give a custom event a name that Adapty Mail uses for its own events: created, updated, email_confirmed, suppressed, deleted, and every event_type of a transaction event, such as subscription_started.

event_idstringrequired

Your unique identifier for this event. It has up to 128 characters. Adapty Mail ignores an event_id it already has, so you can safely retry a request.

event_datetimestringrequired

When the event happened, in ISO 8601 format, in UTC.

external_profile_idstringrequired

The same stable external_profile_id you send when you save the profile. You can send a custom event before the profile exists. When you later save a profile with the same identifier, Adapty Mail links the event to that profile. At that point, the profile can qualify for a purpose on the event.

customer_user_idstring

Identifier of the user in your own system.

emailstring

Email address of the user.

sourcestring
payloadobject

Data to show in emails. It can have up to 50 fields, and each value is a string of up to 1,000 characters. Field names follow the character rules of event_type. Use the names that the purpose lists under Payload fields. Each field appears in emails through its custom event placeholder, such as {{ custom_event.goal }}.

Responses

Custom event received. Adapty Mail applies purpose rules to the event after it responds, so the response doesn't show whether a sequence started. The response body is empty.

Validation failed — a required field is missing or invalid. field_name shows which field.

Schema

Standard error response. Every failure returns a 4XX status with this shape.

errorsarray of object
messagestring

Human-readable description of the error.

error_codestring

Machine-readable error identifier.

status_codeinteger

HTTP status code for this error.

field_namestring

The request field that caused the error, or null if the error isn't field-specific.

Example
{
  "errors": [
    {
      "message": "Field required",
      "error_code": "base_error",
      "status_code": 400,
      "field_name": "event_type"
    }
  ]
}

Missing or invalid secret API key.

Schema

Standard error response. Every failure returns a 4XX status with this shape.

errorsarray of object
messagestring

Human-readable description of the error.

error_codestring

Machine-readable error identifier.

status_codeinteger

HTTP status code for this error.

field_namestring

The request field that caused the error, or null if the error isn't field-specific.

Example
{
  "errors": [
    {
      "message": "Secret key doesn't exist",
      "error_code": "secret_key_does_not_exist_error",
      "status_code": 403,
      "field_name": null
    }
  ]
}