const payload = new Payload({
"name": "com.example.credential",
"mimeType": "application/json",
"icon": "asset:ej1w5zyrqi9m...",
"locales": {
"default": "en_GB",
"values": [
{
"locale": "en_GB",
"infoUri": "https://www.example.com",
"name": "Example Credential Name"
}
]
},
"authz": {
"rules": [
{
"name": "REQUEST",
"orgs": ["a2399abe-c767-4748-ac37-4b726a9f9150"]
},
{
"name": "ISSUE",
"orgs": ["b3ef4e6d-581e-46e7-a373-7da2a88bc76d"]
}
]
}
});
const request = new RequestBuilder()
.withBaseUrl('https://api.yoti.com/api/v1/attribute-registry')
.withEndpoint('/definitions')
.withPemString('PEM_CONTENT')
.withHeader('X-Yoti-Auth-Id', 'CLIENT_SDK_ID')
.withMethod('POST')
.withPayload(payload)
.build();
const response = await request.execute();
String payload = "{ \"name\" : \"com.example.credential\", \"mimeType\" : \"application/json\", \"icon\" : \"asset:ej1w5zyrqi9m...\", \"locales\" : { \"default\" : \"en_GB\", \"values\" : [ { \"locale\" : \"en_GB\", \"infoUri\" : \"https://www.example.com\", \"name\" : \"Example Credential Name\" } ] }, \"authz\" : { \"rules\" : [ { \"name\" : \"REQUEST\", \"orgs\" : [ \"a2399abe-c767-4748-ac37-4b726a9f9150\" ] }, { \"name\" : \"ISSUE\", \"orgs\" : [ \"b3ef4e6d-581e-46e7-a373-7da2a88bc76d\" ] } ] } }";
byte[] payload = payloadString.getBytes("UTF-8");
SignedRequest signedRequest = SignedRequestBuilderFactory.create()
.withKeyPair("PEM_CONTENT")
.withBaseUrl("https://api.yoti.com/api/v1/attribute-registry")
.withEndpoint("/definitions")
.withHttpMethod(HTTP_POST)
.withPayload(payload)
.withHeader("X-Yoti-Auth-Id", "CLIENT_SDK_ID")
.build();
SignedRequestResponse response = signedRequest.execute();
<?php
use Yoti\Http\Payload;
use Yoti\Http\RequestBuilder;
$payload = Payload::fromJsonData((object) [
"name" => "com.example.credential",
"mimeType" => "application/json",
"icon" => "asset:ej1w5zyrqi9m...",
"locales" => (object) [
"default" => "en_GB",
"values" => [
(object)[
"locale" => "en_GB",
"infoUri" => "https://www.example.com",
"name" => "Example Credential Name"
]
]
],
"authz" => (object) [
"rules" => [
(object) [
"name" => "REQUEST",
"orgs" => ["a2399abe-c767-4748-ac37-4b726a9f9150"]
],
(object) [
"name" => "ISSUE",
"orgs" => ["b3ef4e6d-581e-46e7-a373-7da2a88bc76d"]
]
]
]
]);
$request = (new RequestBuilder())
->withBaseUrl('https://api.yoti.com/api/v1/attribute-registry')
->withEndpoint('/definitions')
->withPemFilePath('/path/to/key.pem')
->withHeader('X-Yoti-Auth-Id', 'CLIENT_SDK_ID')
->withMethod('POST')
->withPayload($payload)
->build();
$response = $request->execute();
if ($response->getStatusCode() !== 201) {
// Handle error.
}
// Note:
// - Use RequestBuilder::withPemFile() to provide a `\Yoti\Util\PemFile`
// - Use RequestBuilder::withPemString() to provide PEM string
import json
from yoti_python_sdk.http import SignedRequest
payload_data = {
"name": "your_credential_name",
"schema": { #...
},
"mimeType": "mimeType",
"icon": "base64icon",
"locales": {
"default": "en_GB",
},
"authz": {
#...
}
}
payload_string = json.dumps(payload_data).encode()
signed_request = (
SignedRequest
.builder()
.with_pem_file("/path/to/key.pem")
.with_base_url("https://api.yoti.com/api/v1/attribute-registry")
.with_endpoint("/definitions")
.with_http_method("POST")
.with_header("X-Yoti-Auth-Id", "CLIENT_SDK_ID")
.with_payload(payload_string)
.build()
)
response = signed_request.execute()
HttpClient _httpClient = new HttpClient();
string json = JsonConvert.SerializeObject(new
{
name = 'your_credential_name',
schema = new { },
mimeType = 'mimeType',
icon = 'base64icon',
locales = new {
default: 'en_GB'
},
authz = new { }
});
byte[] httpContent = System.Text.Encoding.UTF8.GetBytes(jsonString);
var signedRequest = new RequestBuilder()
.WithBaseUri(new Uri("https://api.yoti.com/api/v1/attribute-registry"))
.WithEndpoint("/definitions")
.WithHttpMethod(HttpMethod.Post)
.WithHeader("X-Yoti-Auth-Id", _clientSdkId)
.WithKeyPair(keyPair)
.WithContent(httpContent)
.Build();
HttpResponseMessage response = await signedRequest.Execute(_httpClient).ConfigureAwait(false);
type Schema struct {
Title string `json:"title"`
}
type Locale struct {
Default string `json:"default"`
}
type Rule struct {
Name string `json:"name"`
}
type Authz struct {
Rules []Rule `json:"rules"`
}
type Payload struct {
Name string `json:"name"`
Schema Schema `json:"schema"`
MimeType string `json:"mimeType"`
Icon string `json:"icon"`
Locales Locale `json:"locales"`
Authz Authz `json:"authz"`
}
body, err := json.Marshal(Payload{
Name: "your_credential_name",
Schema: Schema{
Title: "your_schema_title",
},
MimeType: "mimeType",
Icon: "base64icon",
Locales: Locale{
Default: "en_GB",
},
Authz: Authz{
Rules: []Rules{
Rule{
Name: "REQUEST" | "ISSUE",
},
},
},
})
if err != nil {
panic(err)
}
headers := map[string][]string{
"X-Yoti-Auth-Id": []string{"CLIENT_SDK_ID"},
}
decodedKey, err := cryptoutil.ParseRSAKey(key)
if err != nil {
panic(err)
}
request, err := requests.SignedRequest{
Key: decodedKey,
HTTPMethod: http.MethodPost,
BaseURL: "https://api.yoti.com/api/v1/attribute-registry",
Endpoint: "/definitions",
Headers: headers,
Body: body,
}.Request()
if err != nil {
panic(err)
}
response, err := requests.Execute(&http.Client{}, request)
payload = {
name: 'your_credential_name',
schema: { #...
} ,
mimeType: 'mimeType',
icon: 'base64icon',
locales: {
default: 'en_GB'
},
authz: { #...
}
}
request = Yoti::Request
.builder
.with_base_url('https://api.yoti.com/api/v1/attribute-registry')
.with_http_method('POST')
.with_endpoint('definitions')
.with_payload(payload)
.with_header('X-Yoti-Auth-Id', 'CLIENT_SDK_ID')
.build
response = request.execute