Creating ServicePrincipals via API

arcrob

Bronze Partner
Basic Certified
Joined
Jan 13, 2022
Messages
22
Reaction score
12
Hi all,

I am creating a small admin site for my clients to add new tenants on to a new Multi Tenant system, All is going ok so far but I have hit a bit of a roadblock with adding a new API user (ServicePrincipals).

There is a lot of fields on the swagger docs but I cannot seem to hit the right fields to get a successful request.

My aim is to create a new SP (API User) with a name, group selected (58 in my test) and Owner rights. That SP will then be used to create users and other bits which all are pretty straight forward but the SP is getting me stuck.

When I query the /ServicePrincipals I get the following:

Swagger guide has the following schema, but I know I won't need to submit all of that, and simply changing the Group IDs and role names, has not provided a valid request.

Has anyone got a working create SP request they can share?

Thanks :)

JSON:
curl -X 'POST' \
  'https://editor.swagger.io/xapi/v1/ServicePrincipals' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "Groups": [
    {
      "CanDelete": true,
      "GroupId": 2147483647,
      "GroupRights": {
        "AllowIVR": true,
        "AllowParking": true,
        "AllowToChangePresence": true,
        "AllowToManageCompanyBook": true,
        "AssignClearOperations": true,
        "CanBargeIn": true,
        "CanIntercom": true,
        "CanSeeGroupCalls": true,
        "CanSeeGroupMembers": true,
        "CanSeeGroupRecordings": true,
        "Invalid": true,
        "PerformOperations": true,
        "RoleName": "string",
        "ShowMyCalls": true,
        "ShowMyPresence": true,
        "ShowMyPresenceOutside": true
      },
      "Id": 2147483647,
      "MemberName": "string",
      "Name": "string",
      "Number": "string",
      "Rights": {
        "AllowIVR": true,
        "AllowParking": true,
        "AllowToChangePresence": true,
        "AllowToManageCompanyBook": true,
        "AssignClearOperations": true,
        "CanBargeIn": true,
        "CanIntercom": true,
        "CanSeeGroupCalls": true,
        "CanSeeGroupMembers": true,
        "CanSeeGroupRecordings": true,
        "Invalid": true,
        "PerformOperations": true,
        "RoleName": "string",
        "ShowMyCalls": true,
        "ShowMyPresence": true,
        "ShowMyPresenceOutside": true
      },
      "Tags": [
        "MS"
      ],
      "TranscriptionMode": "Nothing",
      "Type": "None"
    }
  ],
  "Id": 2147483647,
  "Number": "string",
  "TranscriptionMode": "Nothing",
  "CallControlEnabled": true,
  "LastUsed": "2025-09-20T17:40:46.842Z",
  "MyPhoneEnabled": true,
  "Peers": [
    {
      "Hidden": true,
      "Id": 2147483647,
      "MemberOf": [
        {
          "GroupID": 2147483647,
          "Name": "string",
          "Number": "string",
          "RoleName": "string"
        }
      ],
      "Name": "string",
      "Number": "string",
      "Tags": [
        "MS"
      ],
      "Type": "None"
    }
  ],
  "XAPIEnabled": true
}'
 
Woke up with a fresh mind today, for anyone that hits this in future the answer is;

JSON:
{
  "Id": 0,
  "Number": "test10",
  "XAPIEnabled": true,
  "Groups": [
    {
      "CanDelete": true,
      "GroupId": 58,
      "Rights": {
          "RoleName": "group_owners"
      }
      }
  ]
}
 

Forum statistics

Threads
111,955
Messages
589,926
Members
164,855
Latest member
parik24pro