Create a certificate from an asset.
curl --request POST \
--url 'https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=asset' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Certificate",
"description": "Certificate description",
"assetId": "asset-01",
"from": 1234567,
"to": 1234567,
"content": {},
"public": true,
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}
'import requests
url = "https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=asset"
payload = {
"name": "Certificate",
"description": "Certificate description",
"assetId": "asset-01",
"from": 1234567,
"to": 1234567,
"content": {},
"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',
assetId: 'asset-01',
from: 1234567,
to: 1234567,
content: {},
public: true,
expires: 1234567890,
certificatePin: '1234',
externalId: 'extcertid'
})
};
fetch('https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=asset', 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?type=asset",
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',
'assetId' => 'asset-01',
'from' => 1234567,
'to' => 1234567,
'content' => [
],
'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?type=asset"
payload := strings.NewReader("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"assetId\": \"asset-01\",\n \"from\": 1234567,\n \"to\": 1234567,\n \"content\": {},\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?type=asset")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"assetId\": \"asset-01\",\n \"from\": 1234567,\n \"to\": 1234567,\n \"content\": {},\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?type=asset")
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 \"assetId\": \"asset-01\",\n \"from\": 1234567,\n \"to\": 1234567,\n \"content\": {},\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",
"type": "content",
"content": {},
"issuer": "did:user:{issuer}",
"issuedOn": 1696840286580,
"hash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"expires": 1696840286580
},
"metadata": [
{
"type": "Evidence",
"networkId": 10004,
"smartContract": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"transactionHash": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"trustPointHash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"timestamp": 1696840286580
}
],
"access": {
"public": true,
"certificatePin": "1234",
"externalId": "extcertid"
}
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error",
"message": "User credentials are wrong"
}{
"statusCode": 403,
"type": "Forbidden Error",
"message": "User is not qualified, please try again with a qualified user"
}{
"statusCode": 409,
"type": "Existing certificate error",
"message": "The certificate is already registered, please try again with a different content"
}{
"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 Asset Certificate
Creates a certificate from an existing Track API asset.
POST
/
certificates?type=asset
Create a certificate from an asset.
curl --request POST \
--url 'https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=asset' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Certificate",
"description": "Certificate description",
"assetId": "asset-01",
"from": 1234567,
"to": 1234567,
"content": {},
"public": true,
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}
'import requests
url = "https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=asset"
payload = {
"name": "Certificate",
"description": "Certificate description",
"assetId": "asset-01",
"from": 1234567,
"to": 1234567,
"content": {},
"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',
assetId: 'asset-01',
from: 1234567,
to: 1234567,
content: {},
public: true,
expires: 1234567890,
certificatePin: '1234',
externalId: 'extcertid'
})
};
fetch('https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=asset', 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?type=asset",
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',
'assetId' => 'asset-01',
'from' => 1234567,
'to' => 1234567,
'content' => [
],
'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?type=asset"
payload := strings.NewReader("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"assetId\": \"asset-01\",\n \"from\": 1234567,\n \"to\": 1234567,\n \"content\": {},\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?type=asset")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Certificate\",\n \"description\": \"Certificate description\",\n \"assetId\": \"asset-01\",\n \"from\": 1234567,\n \"to\": 1234567,\n \"content\": {},\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?type=asset")
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 \"assetId\": \"asset-01\",\n \"from\": 1234567,\n \"to\": 1234567,\n \"content\": {},\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",
"type": "content",
"content": {},
"issuer": "did:user:{issuer}",
"issuedOn": 1696840286580,
"hash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"expires": 1696840286580
},
"metadata": [
{
"type": "Evidence",
"networkId": 10004,
"smartContract": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"transactionHash": "0xabcdbcbff5fa05e060e7dfe3e608cba010d11abc",
"trustPointHash": "a2ac9343a3d94e41bbc5c152fb8382c5233a47cee23cf765c7e6d67d9e61a142",
"timestamp": 1696840286580
}
],
"access": {
"public": true,
"certificatePin": "1234",
"externalId": "extcertid"
}
}
}{
"statusCode": 400,
"type": "Validation Error",
"message": "Request parameters are wrong, check requirements",
"errors": [
{
"field": "",
"error": ""
}
]
}{
"statusCode": 401,
"type": "Authentication Error",
"message": "User credentials are wrong"
}{
"statusCode": 403,
"type": "Forbidden Error",
"message": "User is not qualified, please try again with a qualified user"
}{
"statusCode": 409,
"type": "Existing certificate error",
"message": "The certificate is already registered, please try again with a different content"
}{
"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
Query Parameters
Body
application/json
Data needed for the creation of a certificate from an asset.
Was this page helpful?