SQL Server / Braze Endpoints / Update Scheduled API Triggered Campaigns
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
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "campaign_id": "campaign_identifier",
-- "schedule_id": "schedule_identifier",
-- "schedule": {
-- "time": "2017-05-24T21:30:00Z",
-- "in_local_time": true
-- }
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'campaign_id', 'campaign_identifier'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'schedule_id', 'schedule_identifier'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'schedule.time', '2017-05-24T21:30:00Z'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'schedule.in_local_time', 1
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
-- Adds the "Authorization: Bearer {{api_key}}" header.
EXEC sp_OASetProperty @http, 'AuthToken', '{{api_key}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://rest.iad-01.braze.com/campaigns/trigger/schedule/update', 'application/json', @json
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 @json
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 @json
END
GO
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer {{api_key}}"
-d '{
"campaign_id": "campaign_identifier",
"schedule_id": "schedule_identifier",
"schedule": {
"time": "2017-05-24T21:30:00Z",
"in_local_time": true
}
}'
https://rest.iad-01.braze.com/campaigns/trigger/schedule/update
Postman Collection Item JSON
{
"name": "Update Scheduled API Triggered Campaigns",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"type": "text",
"value": "Bearer {{api_key}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"campaign_id\": \"campaign_identifier\",\n \"schedule_id\": \"schedule_identifier\",\n \"schedule\": {\n \"time\": \"2017-05-24T21:30:00Z\",\n \"in_local_time\": true\n }\n}"
},
"url": {
"raw": "https://{{instance_url}}/campaigns/trigger/schedule/update",
"protocol": "https",
"host": [
"{{instance_url}}"
],
"path": [
"campaigns",
"trigger",
"schedule",
"update"
]
},
"description": "Use this endpoint to update scheduled API Triggered Campaigns, which are created on the Dashboard and initiated via the API. You can pass in `trigger_properties` that will be templated into the message itself.\n\nThis endpoint allows you to send Campaign messages via API Triggered delivery, allowing you to decide what action should trigger the message to be sent. Please note that to send messages with this endpoint, you must have a Campaign ID, created when you build an API Triggered Campaign.\n\nAny schedule will completely overwrite the one that you provided in the create schedule request or in previous update schedule requests. For example, if you originally provide `\"schedule\" : {\"time\" : \"2015-02-20T13:14:47\", \"in_local_time\" : true}` and then in your update you provide `\"schedule\" : {\"time\" : \"2015-02-20T14:14:47\"}`, your message will now be sent at the provided time in UTC, not in the user's local time. Scheduled triggers that are updated very close to or during the time they were supposed to be sent will be updated with best efforts, so last-second changes could be applied to all, some, or none of your targeted users.\n\n### Request Parameters\n| Parameter | Required | Data Type | Description |\n| --------- | ---------| --------- | ----------- |\n|`campaign_id`|Required|String| See campaign identifier|\n|`schedule_id`| Optional | String | The schedule_id to update (obtained from the response to create schedule) |\n|`schedule` | Required | Object | See schedule object |\n\n\n## Request Components\n- [Campaign ID](https://www.braze.com/docs/api/identifier_types/)\n- [Schedule Object](https://www.braze.com/docs/api/objects_filters/schedule_object/)"
},
"response": [
]
}