Hello copilot
Authenticate trusted machine
curl -X POST \
'https://<BASE_URL>/v2/api/management/copilot_connect/auth/token' \
-d "{\"grant_type\": \"client_credentials\"}" \
-u <CLIENT_ID>:<CLIENT_SECRET> \
-H 'Content-Type: application/json'
Replace <BASE_URL>
, <CLIENT_ID>
and <CLIENT_SECRET>
with your own content, as provided by Copilot.cx Customer Success Manager. See Configuration.
Example Response:
{
"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwd2RfZXhwaXJlZCI6ZmFsc2UsInVzZXJfcm9sZSI6IlNFUlZJQ0VfQUNDT1VOVCIsImRldmljZV9pZCI6ImVtcHR5IiwidXNlcl9pZCI6IjVjNTA4MmNjZmFmZWYyNTM3M2JiMzc1MiIsImV4cGlyYXRpb25fdGltZSI6MTU1MjQxMjczNzUwNSwiand0VmVyc2lvbiI6Imp3dDEifQ.pF25GcYW1HNLeG1KRVPcD7Zys8MSTdTKBCURS5DF984",
"token_type":"Bearer",
"expires_in":600
}
Keep the returned access_token
and token_type
and use them in your next API calls.
Get Users
Start by getting the Users managed by Copilot:
curl -X GET 'https://<BASE_URL>/v1/api/management/users' \
-H 'Authorization: <token_type> <access_token>' \
-H 'Content-Type: application/json'
The response will be:
{
"users": [],
"nextPage": null
}
Try creating a new End User through your application client, and call the API again. The result should look as below:
{
"users": [
{
"id": "5c88d59a00f138000e9233bc",
"email": "myfirstuser@example.com",
"first_name": "First",
"last_name": "User",
"created_at": "2019-03-13T10:04:10.668Z",
"updated_at": "2019-03-13T10:04:10.668Z"
}
],
"next_page": null
}
Example
The result - successful use of Copilot.cx Management API
~> curl -X POST \
'https://api.this-is-an-example-environment.bycopilot.com/v2/api/management/copilot_connect/auth/token/' \
-d "{\"grant_type\": \"client_credentials\"}" \
-u ABABABABQQIRZ:k9H2Nd3T5j5EW2Fu160l11Hal3x3oa \
-H 'Content-Type: application/json'
{"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwd2RfZXhwaXJlZCI6ZmFsc2UsInVzZXJfcm9sZSI6IlNFUlZJQ0VfQUNDT1VOVCIsImRldmljZV9pZCI6ImVtcHR5IiwidXNlcl9pZCI6IjVjNjE0NDQ2MjZhOGYyMDAwZjY4M2E3NSIsImV4cGlyYXRpb25fdGltZSI6MTU1MjU4MTI5MTA3Niwiand0VmVyc2lvbiI6Imp3dDEifQ.AKDMCMrsljxtFEnK42dgglQOxlaCq5ju7OY7tD1ddSQ","token_type":"Bearer","expires_in":600}
~> curl -X GET \
'https://api.this-is-an-example-environment.bycopilot.com/v2/api/management/copilot_connect/users' \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwd2RfZXhwaXJlZCI6ZmFsc2UsInVzZXJfcm9sZSI6IlNFUlZJQ0VfQUNDT1VOVCIsImRldmljZV9pZCI6ImVtcHR5IiwidXNlcl9pZCI6IjVjNjE0NDQ2MjZhOGYyMDAwZjY4M2E3NSIsImV4cGlyYXRpb25fdGltZSI6MTU1MjU4MTI5MTA3Niwiand0VmVyc2lvbiI6Imp3dDEifQ.AKDMCMrsljxtFEnK42dgglQOxlaCq5ju7OY7tD1ddSQ' \
-H 'Content-Type: application/json'
{"users": [],"nextPage": null}