Chilkat Online Tools

phpExt / Sunshine Conversations API / Delete User

Back to Collection Items

<?php

include("chilkat_9_5_0.php");

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$http = new CkHttp();

$http->put_BasicAuth(true);
$http->put_Login('username');
$http->put_Password('password');

// resp is a CkHttpResponse
$resp = $http->QuickRequest('DELETE','https://domain.com/v2/apps/{{appId}}/users/:userIdOrExternalId');
if ($http->get_LastMethodSuccess() == false) {
    print $http->lastErrorText() . "\n";
    exit;
}

$sbResponseBody = new CkStringBuilder();
$resp->GetBodySb($sbResponseBody);

$jResp = new CkJsonObject();
$jResp->LoadSb($sbResponseBody);
$jResp->put_EmitCompact(false);

print 'Response Body:' . "\n";
print $jResp->emit() . "\n";

$respStatusCode = $resp->get_StatusCode();
print 'Response Status Code = ' . $respStatusCode . "\n";
if ($respStatusCode >= 400) {
    print 'Response Header:' . "\n";
    print $resp->header() . "\n";
    print 'Failed.' . "\n";

    exit;
}


?>

Curl Command

curl -X DELETE
	-u 'username:password'
https://domain.com/v2/apps/{{appId}}/users/:userIdOrExternalId

Postman Collection Item JSON

{
  "name": "Delete User",
  "_postman_id": "9832c907-d520-4724-87af-089b23238386",
  "request": {
    "method": "DELETE",
    "header": [
    ],
    "url": {
      "raw": "{{url}}/v2/apps/{{appId}}/users/:userIdOrExternalId",
      "host": [
        "{{url}}"
      ],
      "path": [
        "v2",
        "apps",
        "{{appId}}",
        "users",
        ":userIdOrExternalId"
      ],
      "variable": [
        {
          "key": "userIdOrExternalId"
        }
      ]
    },
    "description": "Delete a user, its clients and its conversation history. The user is considered completely deleted once the `user:delete` webhook is fired. To only delete a user’s personal information, see [Delete User Personal Information](#operation/deleteUserPersonalInformation)."
  },
  "response": [
    {
      "id": "b0058590-af1b-474f-b113-a208a3b819e6",
      "name": "User not found",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/users/:userIdOrExternalId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "users",
            ":userIdOrExternalId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "userIdOrExternalId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "id": "ee063167-3ed0-49d0-91b6-e9326ad9220a",
      "name": "Ok",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/users/:userIdOrExternalId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "users",
            ":userIdOrExternalId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "userIdOrExternalId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{}"
    }
  ]
}