Skip to content
Documentation/canton-network-docs/Ledger APIOpenAPIView on canton-network-docs
canton-network-docs/Ledger APIOpenAPI

POST /v2/users

POST
/
v2
/
users
Try it
POST /v2/users

cURL

curl --request POST \
  --url https://api.example.com/v2/users \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "user": {
    "id": "<string>",
    "primaryParty": "<string>",
    "isDeactivated": true,
    "metadata": {
      "resourceVersion": "<string>",
      "annotations": {}
    },
    "identityProviderId": "<string>",
    "primaryPartyAuthentication": true
  },
  "rights": [
    {
      "kind": {
        "CanActAs": {
          "value": {
            "party": "<string>"
          }
        }
      }
    }
  ]
}
'
import requests

url = "https://api.example.com/v2/users"

payload = {
    "user": {
        "id": "<string>",
        "primaryParty": "<string>",
        "isDeactivated": True,
        "metadata": {
            "resourceVersion": "<string>",
            "annotations": {}
        },
        "identityProviderId": "<string>",
        "primaryPartyAuthentication": True
    },
    "rights": [{ "kind": { "CanActAs": { "value": { "party": "<string>" } } } }]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    user: {
      id: '<string>',
      primaryParty: '<string>',
      isDeactivated: true,
      metadata: {resourceVersion: '<string>', annotations: {}},
      identityProviderId: '<string>',
      primaryPartyAuthentication: true
    },
    rights: [{kind: {CanActAs: {value: {party: '<string>'}}}}]
  })
};

fetch('https://api.example.com/v2/users', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.example.com/v2/users",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'user' => [
        'id' => '<string>',
        'primaryParty' => '<string>',
        'isDeactivated' => true,
        'metadata' => [
                'resourceVersion' => '<string>',
                'annotations' => [
                                
                ]
        ],
        'identityProviderId' => '<string>',
        'primaryPartyAuthentication' => true
    ],
    'rights' => [
        [
                'kind' => [
                                'CanActAs' => [
                                                                'value' => [
                                                                                                                                'party' => '<string>'
                                                                ]
                                ]
                ]
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v2/users"

	payload := strings.NewReader("{\n  \"user\": {\n    \"id\": \"<string>\",\n    \"primaryParty\": \"<string>\",\n    \"isDeactivated\": true,\n    \"metadata\": {\n      \"resourceVersion\": \"<string>\",\n      \"annotations\": {}\n    },\n    \"identityProviderId\": \"<string>\",\n    \"primaryPartyAuthentication\": true\n  },\n  \"rights\": [\n    {\n      \"kind\": {\n        \"CanActAs\": {\n          \"value\": {\n            \"party\": \"<string>\"\n          }\n        }\n      }\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.example.com/v2/users")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"user\": {\n    \"id\": \"<string>\",\n    \"primaryParty\": \"<string>\",\n    \"isDeactivated\": true,\n    \"metadata\": {\n      \"resourceVersion\": \"<string>\",\n      \"annotations\": {}\n    },\n    \"identityProviderId\": \"<string>\",\n    \"primaryPartyAuthentication\": true\n  },\n  \"rights\": [\n    {\n      \"kind\": {\n        \"CanActAs\": {\n          \"value\": {\n            \"party\": \"<string>\"\n          }\n        }\n      }\n    }\n  ]\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v2/users")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"user\": {\n    \"id\": \"<string>\",\n    \"primaryParty\": \"<string>\",\n    \"isDeactivated\": true,\n    \"metadata\": {\n      \"resourceVersion\": \"<string>\",\n      \"annotations\": {}\n    },\n    \"identityProviderId\": \"<string>\",\n    \"primaryPartyAuthentication\": true\n  },\n  \"rights\": [\n    {\n      \"kind\": {\n        \"CanActAs\": {\n          \"value\": {\n            \"party\": \"<string>\"\n          }\n        }\n      }\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
200
400
default
{
  "user": {
    "id": "<string>",
    "primaryParty": "<string>",
    "isDeactivated": true,
    "metadata": {
      "resourceVersion": "<string>",
      "annotations": {}
    },
    "identityProviderId": "<string>",
    "primaryPartyAuthentication": true
  }
}
"<string>"
{
  "code": "<string>",
  "cause": "<string>",
  "context": {},
  "errorCategory": 123,
  "correlationId": "<string>",
  "traceId": "<string>",
  "resources": [
    [
      "<string>"
    ]
  ],
  "grpcCodeValue": 123,
  "retryInfo": "<string>",
  "definiteAnswer": true
}

Authorizations

Authorization
string
header
required

Ledger API standard JWT token

Body

application/json

RPC requests and responses /////////////////////////// Required authorization: HasRight(ParticipantAdmin) OR IsAuthenticatedIdentityProviderAdmin(user.identity_provider_id)

user
User · object
required

The user to create.

Required

Show child attributes

rights
Right · object[]

The rights to be assigned to the user upon creation, which SHOULD include appropriate rights for the user.primary_party.

Optional: can be empty

Show child attributes

Response

200
application/json
user
User · object
required

Created user.

Required

Show child attributes