Chilkat Online Tools

SQL Server / Braze Endpoints / List Available Email Templates

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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'modified_after', '2020-01-01T01:01:01.000000'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'modified_before', '2020-02-01T01:01:01.000000'
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'limit', 1
    EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'offset', 0

    -- 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/templates/email/list', @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 "modified_after=2020-01-01T01%3A01%3A01.000000"
	-d "modified_before=2020-02-01T01%3A01%3A01.000000"
	-d "limit=1"
	-d "offset=0"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/templates/email/list

Postman Collection Item JSON

{
  "name": "List Available Email Templates",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/templates/email/list?modified_after=2020-01-01T01:01:01.000000&modified_before=2020-02-01T01:01:01.000000&limit=1&offset=0",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "templates",
        "email",
        "list"
      ],
      "query": [
        {
          "key": "modified_after",
          "value": "2020-01-01T01:01:01.000000",
          "description": "(Optional) String in ISO 8601\n\nRetrieve only templates updated at or after the given time."
        },
        {
          "key": "modified_before",
          "value": "2020-02-01T01:01:01.000000",
          "description": "(Optional) String in ISO 8601\n\nRetrieve only templates updated at or before the given time"
        },
        {
          "key": "limit",
          "value": "1",
          "description": "(Optional) Positive Number\n\nMaximum number of templates to retrieve, default to 100 if not provided, maximum acceptable value is 1000."
        },
        {
          "key": "offset",
          "value": "0",
          "description": "(Optional) Positive Number\n\nNumber of templates to skip before returning rest of the templates that fit the search criteria."
        }
      ]
    },
    "description": "Use this endpoint to get a list of available templates in your Braze account.\n\nUse the Template REST APIs to programmatically manage the email templates that you have stored on the Braze dashboard, on the Templates & Media page. Braze provides two endpoints for creating and updating your email templates.\n\n### Successful Response Properties\n```json\n{\n  \"count\": number of templates returned\n  \"templates\": [template with the following properties]:\n    \"email_template_id\": (string) your email template's API Identifier,\n    \"template_name\": (string) the name of your email template,\n    \"created_at\": (string, in ISO 8601),\n    \"updated_at\": (string, in ISO 8601),\n    \"tags\": (array of strings) tags appended to the template\n}\n  ```"
  },
  "response": [
  ]
}