Create a certificate from a file.
curl --request POST \
--url 'https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form fileInput=@example-file \
--form 'body={
"name": "Certificate",
"description": "Certificate description",
"content": {},
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}'import requests
url = "https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file"
files = { "fileInput": ("example-file", open("example-file", "rb")) }
payload = { "body": "{
\"name\": \"Certificate\",
\"description\": \"Certificate description\",
\"content\": {},
\"expires\": 1234567890,
\"certificatePin\": \"1234\",
\"externalId\": \"extcertid\"
}" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('fileInput', '<string>');
form.append('body', '{
"name": "Certificate",
"description": "Certificate description",
"content": {},
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file', 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=file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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=file"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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=file")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--"
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 File Certificate
Creates a certificate from a file.
POST
/
certificates?type=file
Create a certificate from a file.
curl --request POST \
--url 'https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form fileInput=@example-file \
--form 'body={
"name": "Certificate",
"description": "Certificate description",
"content": {},
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}'import requests
url = "https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file"
files = { "fileInput": ("example-file", open("example-file", "rb")) }
payload = { "body": "{
\"name\": \"Certificate\",
\"description\": \"Certificate description\",
\"content\": {},
\"expires\": 1234567890,
\"certificatePin\": \"1234\",
\"externalId\": \"extcertid\"
}" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('fileInput', '<string>');
form.append('body', '{
"name": "Certificate",
"description": "Certificate description",
"content": {},
"expires": 1234567890,
"certificatePin": "1234",
"externalId": "extcertid"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file', 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=file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$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=file"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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=file")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://lab.trustos.telefonicatech.com/cert/v2/certificates?type=file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"fileInput\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"body\"\r\n\r\n{\r\n \"name\": \"Certificate\",\r\n \"description\": \"Certificate description\",\r\n \"content\": {},\r\n \"expires\": 1234567890,\r\n \"certificatePin\": \"1234\",\r\n \"externalId\": \"extcertid\"\r\n}\r\n-----011000010111000001101001--"
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
multipart/form-data
Data needed for the creation of a certificate from a file.
Was this page helpful?