Chilkat Online Tools

SQL Server / Braze Endpoints / Query Hard Bounced Emails

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'start_date', '2019-01-01'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'end_date', '2019-02-01'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'limit', 100
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'offset', 1
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'email', 'example@braze.com'

    -- Adds the "Authorization: Bearer {{api_key}}" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '{{api_key}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://rest.iad-01.braze.com/email/hard_bounces', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams


END
GO

Curl Command

curl -G -d "start_date=2019-01-01"
	-d "end_date=2019-02-01"
	-d "limit=100"
	-d "offset=1"
	-d "email=example%40braze.com"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/email/hard_bounces

Postman Collection Item JSON

{
  "name": "Query Hard Bounced Emails",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/email/hard_bounces?start_date=2019-01-01&end_date=2019-02-01&limit=100&offset=1&email=example@braze.com",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "email",
        "hard_bounces"
      ],
      "query": [
        {
          "key": "start_date",
          "value": "2019-01-01",
          "description": "(Optional*) String in YYYY-MM-DD format \n\nStart date of the range to retrieve hard bounces, must be earlier than `end_date`. This is treated as midnight in UTC time by the API.\n\n*You must provide either an `email` or a `start_date`, and an `end_date`.\n"
        },
        {
          "key": "end_date",
          "value": "2019-02-01",
          "description": "(Optional*) String in YYYY-MM-DD format\n\nString in YYYY-MM-DD format. End date of the range to retrieve hard bounces. This is treated as midnight in UTC time by the API.\n\n*You must provide either an `email` or a `start_date`, and an `end_date`."
        },
        {
          "key": "limit",
          "value": "100",
          "description": "(Optional) Integer\n\nOptional field to limit the number of results returned. Defaults to 100, maximum is 500."
        },
        {
          "key": "offset",
          "value": "1",
          "description": "(Optional) Integer\n\nOptional beginning point in the list to retrieve from."
        },
        {
          "key": "email",
          "value": "example@braze.com",
          "description": "(Optional*) String\n\nIf provided, we will return whether or not the user has hard bounced.\n\n*You must provide either an `email` or a `start_date`, and an `end_date`."
        }
      ]
    },
    "description": "This endpoint allows you to pull a list of email addresses that have “hard bounced” your email messages within a certain time frame.\n\n> You must provide an `end_date`, as well as either an `email` or a `start_date`.<br><br>If your date range has more than `limit` number of hard bounces, you will need to make multiple API calls, each time increasing the `offset` until a call returns either fewer than `limit` or zero results.\n\n## Response\n\nEntries are listed in descending order.\n\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR-REST-API-KEY\n{\n  \"emails\": [\n    {\n      \"email\": \"example1@braze.com\",\n      \"hard_bounced_at\": \"2016-08-25 15:24:32 +0000\"\n    },\n    {\n      \"email\": \"example2@braze.com\",\n      \"hard_bounced_at\": \"2016-08-24 17:41:58 +0000\"\n    },\n    {\n      \"email\": \"example3@braze.com\",\n      \"hard_bounced_at\": \"2016-08-24 12:01:13 +0000\"\n    }\n  ],\n  \"message\": \"success\"\n}\n```"
  },
  "response": [
  ]
}