Create a certificate.
curl --request POST \
--url https://lab.trustos.telefonicatech.com/cert/v2/certificates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Certificate",
"description": "Certificate description",
"content": {
"key": "value"
},
"public": true,
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}
'import requests
url = "https://lab.trustos.telefonicatech.com/cert/v2/certificates"
payload = {
"name": "Certificate",
"description": "Certificate description",
"content": { "key": "value" },
"public": True,
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}
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({
name: 'Certificate',
description: 'Certificate description',
content: {key: 'value'},
public: true,
expires: 1234567890,
certificatePin: '1234',
externalId: 'extcertid'
})
};
fetch('https://lab.trustos.telefonicatech.com/cert/v2/certificates', 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://lab.trustos.telefonicatech.com/cert/v2/certificates",
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([
'name' => 'Certificate',
'description' => 'Certificate description',
'content' => [
'key' => 'value'
],
'public' => true,
'expires' => 1234567890,
'certificatePin' => '1234',
'externalId' => 'extcertid'
]),
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://lab.trustos.telefonicatech.com/cert/v2/certificates"
payload := strings.NewReader("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"content\": {\n \"key\": \"value\"\n },\n \"public\": true,\n \"expires\": 1234567890,\n \"certificatePin\": \"1234\",\n \"externalId\": \"extcertid\"\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://lab.trustos.telefonicatech.com/cert/v2/certificates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"content\": {\n \"key\": \"value\"\n },\n \"public\": true,\n \"expires\": 1234567890,\n \"certificatePin\": \"1234\",\n \"externalId\": \"extcertid\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/cert/v2/certificates")
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 \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"content\": {\n \"key\": \"value\"\n },\n \"public\": true,\n \"expires\": 1234567890,\n \"certificatePin\": \"1234\",\n \"externalId\": \"extcertid\"\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 201,
"message": "Certificate created",
"data": {
"certID": "did:local:certid:123124",
"data": {
"name": "Certificate",
"description": "Certificate description",
"content": {},
"issuer": "did:user:{issuer}",
"issuedOn": 1696840286580,
"hash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"expires": 1696840286580
},
"metadata": [
{
"networkId": 10004,
"smartContract": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"transactionHash": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"trustPointHash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"timestamp": 1696840286580
}
],
"access": {
"certificatePin": "1234",
"externalId": "extcertid"
}
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error"
}{
"statusCode": 403,
"type": "Forbidden Error"
}{
"statusCode": 409,
"type": "Existing certificate error"
}{
"statusCode": 429,
"type": "Out of Credits Error",
"message": "User has run out of credits. Please, contact BTeam to increase the limit"
}{
"statusCode": 500,
"type": "Internal Server Error",
"message": "Oops! Something went wrong, please try again later"
}Certificate Issuance
Create Certificate
Creates a certificate from a specific content.
POST
/
certificates
Create a certificate.
curl --request POST \
--url https://lab.trustos.telefonicatech.com/cert/v2/certificates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Certificate",
"description": "Certificate description",
"content": {
"key": "value"
},
"public": true,
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}
'import requests
url = "https://lab.trustos.telefonicatech.com/cert/v2/certificates"
payload = {
"name": "Certificate",
"description": "Certificate description",
"content": { "key": "value" },
"public": True,
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}
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({
name: 'Certificate',
description: 'Certificate description',
content: {key: 'value'},
public: true,
expires: 1234567890,
certificatePin: '1234',
externalId: 'extcertid'
})
};
fetch('https://lab.trustos.telefonicatech.com/cert/v2/certificates', 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://lab.trustos.telefonicatech.com/cert/v2/certificates",
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([
'name' => 'Certificate',
'description' => 'Certificate description',
'content' => [
'key' => 'value'
],
'public' => true,
'expires' => 1234567890,
'certificatePin' => '1234',
'externalId' => 'extcertid'
]),
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://lab.trustos.telefonicatech.com/cert/v2/certificates"
payload := strings.NewReader("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"content\": {\n \"key\": \"value\"\n },\n \"public\": true,\n \"expires\": 1234567890,\n \"certificatePin\": \"1234\",\n \"externalId\": \"extcertid\"\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://lab.trustos.telefonicatech.com/cert/v2/certificates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"content\": {\n \"key\": \"value\"\n },\n \"public\": true,\n \"expires\": 1234567890,\n \"certificatePin\": \"1234\",\n \"externalId\": \"extcertid\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/cert/v2/certificates")
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 \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"content\": {\n \"key\": \"value\"\n },\n \"public\": true,\n \"expires\": 1234567890,\n \"certificatePin\": \"1234\",\n \"externalId\": \"extcertid\"\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 201,
"message": "Certificate created",
"data": {
"certID": "did:local:certid:123124",
"data": {
"name": "Certificate",
"description": "Certificate description",
"content": {},
"issuer": "did:user:{issuer}",
"issuedOn": 1696840286580,
"hash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"expires": 1696840286580
},
"metadata": [
{
"networkId": 10004,
"smartContract": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"transactionHash": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"trustPointHash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"timestamp": 1696840286580
}
],
"access": {
"certificatePin": "1234",
"externalId": "extcertid"
}
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error"
}{
"statusCode": 403,
"type": "Forbidden Error"
}{
"statusCode": 409,
"type": "Existing certificate error"
}{
"statusCode": 429,
"type": "Out of Credits Error",
"message": "User has run out of credits. Please, contact BTeam to increase the limit"
}{
"statusCode": 500,
"type": "Internal Server Error",
"message": "Oops! Something went wrong, please try again later"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Flag that indicates whether the certificate should be qualified sign.
Available options:
true, false Network identifier where the trustpoint will be registered.
Example:
10004
Body
application/json
Data needed for the creation of a certificate.
Name of the certificate.
Example:
"Certificate"
Description of the certificate.
Example:
"Certificate description"
Content to certify.
Example:
{ "key": "value" }
Flag that indicates whether the certificate is public or not.
Example:
true
Timestamp of the expiration date of the certificate.
Example:
1234567890
PIN of the certificate.
Example:
"1234"
Custom identifier of the certificate.
Example:
"extcertid"
Was this page helpful?
⌘I