Chilkat Online Tools

SQL Server / Braze Endpoints / User Delete

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

    -- Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    -- The following JSON is sent in the request body.

    -- {
    --   "external_ids": [
    --     "external_identifier1",
    --     "external_identifier2"
    --   ],
    --   "user_aliases": [
    --     "user_alias1",
    --     "user_alias2"
    --   ],
    --   "braze_ids": [
    --     "braze_identifier1",
    --     "braze_identifier2"
    --   ]
    -- }

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

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'external_ids[0]', 'external_identifier1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'external_ids[1]', 'external_identifier2'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'user_aliases[0]', 'user_alias1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'user_aliases[1]', 'user_alias2'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'braze_ids[0]', 'braze_identifier1'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'braze_ids[1]', 'braze_identifier2'

    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/users/delete', '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 '{
  "external_ids": ["external_identifier1", "external_identifier2"],
  "user_aliases": ["user_alias1", "user_alias2"],
  "braze_ids": ["braze_identifier1", "braze_identifier2"]
}'
https://rest.iad-01.braze.com/users/delete

Postman Collection Item JSON

{
  "name": "User Delete",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Authorization",
        "type": "text",
        "value": "Bearer {{api_key}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"external_ids\": [\"external_identifier1\", \"external_identifier2\"],\n  \"user_aliases\": [\"user_alias1\", \"user_alias2\"],\n  \"braze_ids\": [\"braze_identifier1\", \"braze_identifier2\"]\n}"
    },
    "url": {
      "raw": "https://{{instance_url}}/users/delete",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "users",
        "delete"
      ]
    },
    "description": "This endpoint allows you to delete any user profile by specifying a known user identifier. Up to 50 `external_ids`, `user_aliases`, or `braze_ids` can be included in a single request. Only one of `external_ids`, `user_aliases`, or `braze_ids` can be included in a single request.\n\n> Deleting user profiles CANNOT be undone. It will PERMANENTLY remove users which may cause discrepancies in your data. Learn more about [what happens when you delete a user profile via API](https://braze.com/docs/help/help_articles/api/delete_user/) in our Help documentation.\n\n### Request Parameter\n| Parameter | Required | Data Type | Description |\n| --------- | ---------| --------- | ----------- |\n| `external_ids` | Optional | Array of strings | External identifiers for the users to delete |\n| `user_aliases` | Optional | Array of user alias oblect | User aliases for the users to delete |\n| `braze_ids` | Optional | Array of strings | Braze user identifiers for the users to delete |\n\n### Request Components\n- [User Alias Object](https://www.braze.com/docs/api/objects_filters/user_alias_object/)"
  },
  "response": [
  ]
}