콘텐츠로 건너뛰기

API 트리거 전달을 사용하여 트랜잭션 이메일 보내기

post

/transactional/v1/campaigns/{campaign_id}/send

이 엔드포인트를 사용하면 지정된 사용자에게 즉각적인 일회성 트랜잭션 메시지를 보낼 수 있습니다.

이 엔드포인트는 Braze 트랜잭션 이메일 Campaign을 생성하고 해당 Campaign ID와 함께 사용합니다.

트리거 Campaign 전송 엔드포인트와 마찬가지로, 이 Campaign 유형을 사용하면 메시지 콘텐츠를 Braze 대시보드 내에 보관하면서 메시지를 언제, 누구에게 보낼지 API를 통해 지정할 수 있습니다. 메시지를 보낼 오디언스나 Segment를 지정할 수 있는 트리거 Campaign 전송 엔드포인트와 달리, 이 엔드포인트에 대한 요청은 external_user_id 또는 user_alias로 단일 사용자를 지정해야 합니다. 이 Campaign 유형은 주문 확인이나 비밀번호 재설정 같은 알림을 1:1로 보내기 위해 특별히 설계되었기 때문입니다.

트랜잭션 이메일 Campaign은 /campaigns/trigger/send 또는 /campaigns/trigger/schedule/create를 통해 보내지 마세요. 이 엔드포인트들은 트랜잭션 이메일 Campaign ID에 대해 400 오류를 반환합니다.

필수 조건

이 엔드포인트를 사용하려면 transactional.send 권한이 있는 API 키를 생성해야 합니다.

사용량 제한

/transactional/v1/campaigns/{campaign_id}/send 엔드포인트에는 단위로 측정되는 유료 시간당 할당량이 있습니다(예: 패키지에 따라 시간당 50,000단위). 이 엔드포인트에는 엔드포인트별 사용량 제한이 별도로 없습니다. 할당량을 초과한 요청도 전송되지만, SLA는 할당된 볼륨에만 적용됩니다. SLA가 적용되는 볼륨 내에서는 이메일의 99.9%가 1분 이내에 전송됩니다. 트랜잭션 볼륨 카운트는 매시간 초기화됩니다.

이 엔드포인트에 대한 요청은 전체 외부 API 사용량 제한에 포함되지 않습니다. 이 엔드포인트는 표준 REST API 사용량 제한조치를 우회하므로, 표준 X-RateLimit-* 응답 헤더나 한도 초과에 따른 429 응답을 반환하지 않습니다. 자세한 내용은 Braze 지원팀에 문의하세요.

경로 매개변수

매개변수 필수 데이터 유형 설명
campaign_id 필수 문자열 Campaign의 ID

요청 본문

Content-Type: application/json
Authorization: Bearer YOUR-REST-API-KEY
{
  "external_send_id": (optional, string) see the following request parameters,
  "trigger_properties": (optional, object) personalization key-value pairs that apply to the user in this request,
  "recipient": (required, object)
    {
      // Either "external_user_id" or "user_alias" is required. Requests must specify only one.
      "user_alias": (optional, User alias object) User alias of the user to receive message,
      "external_user_id": (optional, string) External identifier of user to receive message,
      "attributes": (optional, object) fields in the attributes object create or update an attribute of that name with the given value on the specified user profile before the message is sent and existing values are overwritten
    }
}

요청 매개변수

매개변수 필수 데이터 유형 설명
external_send_id 선택 사항 문자열 Base64 호환 문자열입니다. 다음 정규식으로 유효성을 검사합니다.

/^[a-zA-Z0-9-_+\/=]+$/

이 선택적 필드를 사용하면 이 특정 전송에 대한 내부 식별자를 전달할 수 있으며, 이 식별자는 트랜잭션 HTTP 이벤트 포스트백에서 전송되는 이벤트에 포함됩니다. 이 식별자를 전달하면 중복 제거 키로도 사용되며, Braze는 이를 24시간 동안 저장합니다.

다른 요청에서 동일한 식별자를 전달하면 24시간 동안 Braze에서 새로운 전송 인스턴스가 생성되지 않습니다.
trigger_properties 선택 사항 오브젝트 트리거 속성정보를 참조하세요. 이 요청에서 사용자에게 적용되는 개인화 키-값 페어입니다.
recipient 필수 오브젝트 이 메시지를 타겟팅하는 사용자입니다. attributes 및 단일 external_user_id 또는 user_alias를 포함할 수 있습니다.

Braze에 아직 존재하지 않는 외부 사용자 ID를 제공하는 경우, attributes 오브젝트에 필드를 전달하면 Braze에 이 고객 프로필이 생성되고 새로 생성된 사용자에게 이 메시지가 전송됩니다.

동일한 사용자에게 attributes 오브젝트에 서로 다른 데이터를 포함하여 여러 요청을 보내면 first_name, last_name, email 속성이 동기적으로 업데이트되고 메시지에 템플릿화됩니다. 커스텀 속성에는 이와 같은 보호 기능이 없으므로 이 API를 통해 사용자를 업데이트하면서 서로 다른 커스텀 속성 값을 빠르게 연속해서 전달할 때는 주의하세요.

요청 예시

curl -X POST \
  -H 'Content-Type:application/json' \
  -H 'Authorization: Bearer YOUR-REST-API-KEY' \
  -d '{
        "external_send_id" : YOUR_BASE64_COMPATIBLE_ID
        "trigger_properties": {
          "example_string_property": YOUR_EXAMPLE_STRING,
          "example_integer_property": YOUR_EXAMPLE_INTEGER
        },
        "recipient": {
          "external_user_id": TARGETED_USER_ID_STRING
        }
      }' \
  https://rest.iad-01.braze.com/transactional/v1/campaigns/{campaign_id}/send

응답

트랜잭션 이메일 전송 엔드포인트는 이 메시지 전송의 인스턴스를 나타내는 메시지의 dispatch_id로 응답합니다. 이 식별자를 트랜잭션 HTTP 이벤트 포스트백의 이벤트와 함께 사용하면 단일 사용자에게 전송된 개별 이메일의 상태를 추적할 수 있습니다.

응답 예시

{
    "dispatch_id": A randomly-generated unique ID of the instance of this send
    "status": Current status of the message
    "metadata" : Object containing additional information about the send instance
}

문제 해결

엔드포인트는 경우에 따라 오류 코드와 사람이 읽을 수 있는 메시지를 반환할 수도 있으며, 대부분은 유효성 검사 오류입니다. 다음은 잘못된 요청을 보낼 때 발생할 수 있는 일반적인 오류입니다.

오류 문제 해결
The campaign is not a transactional campaign. Only transactional campaigns may use this endpoint 제공된 Campaign ID가 트랜잭션 Campaign의 ID가 아닙니다.
The external reference has been queued. Please retry to obtain send_id. external_send_id가 최근에 생성되었습니다. 새 메시지를 전송하려는 경우 새 external_send_id를 사용해 보세요.
Campaign does not exist 제공된 Campaign ID가 기존 Campaign과 일치하지 않습니다.
The campaign is archived. Unarchive the campaign in order for trigger requests to take effect. 제공된 Campaign ID가 아카이브된 Campaign에 해당합니다.
The campaign is paused. Resume the campaign in order for trigger requests to take effect. 제공된 Campaign ID가 일시 중지된 Campaign에 해당합니다.
campaign_id must be a string of the campaign api identifier 제공된 Campaign ID가 올바른 형식이 아닙니다.
Error authenticating credentials 제공된 API 키가 유효하지 않습니다.
Invalid whitelisted IPs 요청을 전송하는 IP 주소가 IP 화이트리스트에 없습니다(화이트리스트를 사용하는 경우).
You do not have permission to access this resource 사용된 API 키에 이 작업을 수행할 권한이 없습니다.

이 엔드포인트는 트랜잭션 할당량을 초과해도 429 응답을 반환하지 않습니다. 할당량, SLA, 응답 헤더에 대한 자세한 내용은 사용량 제한을 참조하세요.

트랜잭션 HTTP 이벤트 포스트백

모든 트랜잭션 이메일은 지정된 URL로 HTTP 요청 형태로 전송되는 이벤트 상태 포스트백으로 보완됩니다. 이를 통해 실시간으로 메시지 상태를 평가하고, 메시지가 전달되지 않은 경우 다른 채널을 통해 사용자에게 도달하기 위한 조치를 취하거나, Braze에 지연이 발생하는 경우 내부 시스템으로 대체할 수 있습니다.

고유 식별자를 사용하여 이러한 업데이트를 개별 메시지에 연결할 수 있습니다:

  • dispatch_id: Braze가 각 메시지에 대해 자동으로 생성하는 고유 ID입니다.
  • external_send_id: 주문 번호와 같이 업데이트를 내부 시스템과 매칭하기 위해 제공하는 커스텀 식별자입니다.

예를 들어, 주문 확인 이메일을 보낼 때 요청에 external_send_id: 1234를 포함하면, 해당 이메일에 대한 모든 후속 이벤트 포스트백(예: Sent 또는 Delivered)에 external_send_id: 1234가 포함됩니다. 이를 통해 주문 #1234의 고객이 주문 확인 이메일을 수신했는지 확인할 수 있습니다.

포스트백 설정하기

Braze 대시보드에서:

  1. 설정 > 이메일 환경설정으로 이동합니다.
  2. 트랜잭션 이벤트 상태 포스트백 아래에서, Braze가 트랜잭션 이메일에 대한 상태 업데이트를 보낼 URL을 입력합니다.
  3. 포스트백을 테스트합니다.

이메일 환경설정의 트랜잭션 이벤트 상태 포스트백 URL 필드

포스트백 본문

{
  "dispatch_id": (string, a randomly-generated unique ID of the instance of this send),
  "status": (string, Current status of message from the following message status table,
  "metadata" : (object, additional information relating to the execution of an event)
   {
     "external_send_id" : (string, If provided at the time of the request, Braze will pass your internal identifier for this send for all postbacks),
     "campaign_api_id" : (string, API identifier of this transactional campaign),
     "received_at": (ISO 8601 DateTime string, Timestamp of when the request was received by Braze, only included for events with "sent" status),
     "enqueued_at": (ISO 8601 DateTime string, Timestamp of when the request was enqueued by Braze, only included for events with "sent" status),
     "executed_at": (ISO 8601 DateTime string, Timestamp of when the request was processed by Braze, only included for events with "sent" status),
     "sent_at": (ISO 8601 DateTime string, Timestamp of when the request was sent to the ESP by Braze, only included for events with "sent" status),
     "processed_at" : (ISO 8601 DateTime string, Timestamp the event was processed by the ESP, only included for events with "processed" status),
     "delivered_at" : (ISO 8601 DateTime string, Timestamp the event was delivered to the user's inbox provider, only included for events with "processed" status),
     "bounced_at" : (ISO 8601 DateTime string, Timestamp the event was bounced by the user's inbox provider, only included for events with "bounced" status),
     "aborted_at" : (ISO 8601 DateTime string, Timestamp the event was Aborted by Braze, only included for events with "aborted" status),
     "reason" : (string, The reason Braze or the Inbox provider was unable to process this message to the user, only included for events with "aborted" or "bounced" status),
   }
}

메시지 상태

상태 설명
sent Braze 이메일 발송 파트너에게 메시지가 성공적으로 전달되었습니다
processed 이메일 발송 파트너가 사용자의 받은편지함 제공업체로 보낼 메시지를 성공적으로 수신하고 준비했습니다
aborted 사용자에게 이메일 가능한 주소가 없거나 메시지 본문에서 Liquid 중단 로직이 호출되어 Braze가 메시지를 성공적으로 발송할 수 없었습니다. 중단된 모든 이벤트에는 메시지가 중단된 이유를 나타내는 메타데이터 오브젝트 내의 reason 필드가 포함됩니다
delivered 사용자의 이메일 받은편지함 제공업체에서 메시지를 수락했습니다
bounced 사용자의 이메일 받은편지함 제공업체에서 메시지를 거부했습니다. 모든 반송 이벤트에는 받은편지함 제공업체가 제공한 반송 오류 코드를 반영하는 메타데이터 오브젝트 내의 reason 필드가 포함됩니다

포스트백 예시


// Sent Event
{
    "dispatch_id": "acf471119f7449d579e8089032003ded",
    "status": "sent",
    "metadata": {
      "received_at": "2020-08-31T18:58:41.000+00:00",
      "enqueued_at": "2020-08-31T18:58:41.000+00:00",
      "executed_at": "2020-08-31T18:58:41.000+00:00",
      "sent_at": "2020-08-31T18:58:42.000+00:00",
      "campaign_api_id": "417220e4-5a2a-b634-7f7d-9ec891532368",
      "external_send_id" : "34a2ceb3cf6184132f3d816e9984269a"
    }
}

// Processed Event
{
    "dispatch_id": "acf471119f7449d579e8089032003ded",
    "status": "processed",
    "metadata": {
      "processed_at": "2020-08-31T18:58:42.000+00:00",
      "campaign_api_id": "417220e4-5a2a-b634-7f7d-9ec891532368",
      "external_send_id" : "34a2ceb3cf6184132f3d816e9984269a"
    }
}

// Aborted
{
    "dispatch_id": "acf471119f7449d579e8089032003ded",
    "status": "aborted",
    "metadata": {
      "reason": "User not emailable",
      "aborted_at": "2020-08-31T19:04:51.000+00:00",
      "campaign_api_id": "417220e4-5a2a-b634-7f7d-9ec891532368",
      "external_send_id" : "34a2ceb3cf6184132f3d816e9984269a"
    }
}

// Delivered Event
{
    "dispatch_id": "acf471119f7449d579e8089032003ded",
    "status": "delivered",
    "metadata": {
      "delivered_at": "2020-08-31T18:27:32.000+00:00",
      "campaign_api_id": "417220e4-5a2a-b634-7f7d-9ec891532368",
      "external_send_id" : "34a2ceb3cf6184132f3d816e9984269a"
    }
}

// Bounced Event
{
    "dispatch_id": "acf471119f7449d579e8089032003ded",
    "status": "bounced",
    "metadata": {
      "bounced_at": "2020-08-31T18:58:43.000+00:00",
      "reason": "550 5.1.1 The email account that you tried to reach does not exist",
      "campaign_api_id": "417220e4-5a2a-b634-7f7d-9ec891532368",
      "external_send_id" : "34a2ceb3cf6184132f3d816e9984269a"
    }
}

New Stuff!