Certificate Routes
This page provides routes for managing certificates. The following routes are available:
POST /
Creates a new certificate.
Description: This endpoint creates a new certificate in the system.
Authentication: This route requires authentication with write, certificate_management, and create permissions. Parameters: None
Request Body:
json
{
"certificateId": "ORG/Cert123",
"issuedTo": "johndoe@example.com",
"template": "66ac70d21f9283220323f34d",
"metadata": {
"for": "John Doe",
"award": "ABC",
"date": "12/02/2024",
"sign": "JD"
}
}certificateId(string, required): The unique identifier for the certificate.issuedTo(string, required): The email address of the recipient.template(string, required): The ID of the certificate template.metadata(object, required): The metadata associated with the certificate.
Response:
- Success Response (201 Created):
json
{
"certificate": {
"certificateId": "ORG/Cert123",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": "6694ff34361b2488daa17354",
"issuedDate": "2024-09-07T18:30:00.000Z",
"issuedTo": "johndoe@example.com",
"metadata": {
"for": "John Doe",
"award": "ABC",
"date": "12/02/2024",
"sign": "JD"
},
"template": "66ac70d21f9283220323f34d",
"txnHash": "0xfb1be491e56da18d9dbf2fcabac7f72c09ed04f3e8a548af8ac4b2d1d617fb8b",
"id": "66b5e0ce3e98c3ffdc954a16"
}
}- Error Response (400 Bad Request):
json
{
"error": "Invalid request body"
}Errors:
- 400 Bad Request: Returned when the request body is invalid or missing required fields.
Usage: To create a new certificate in the blockchain, send a POST request to / with the required certificate data in the request body. A copy of the certificate is saved in the database, and a congratulatory email is sent.
GET /
Retrieves all certificates.
Description: This endpoint retrieves a list of all certificates for the authenticated organization in the system.
Authentication: This route requires authentication with the 'read' permission.
Parameters: None
Response:
- Success Response (200 OK):
json
{
"certificates": [
{
"certificateId": "FEST/org-123",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": "6694ff34361b2488daa17354",
"issuedDate": "2024-09-08T00:00:00.000Z",
"issuedTo": "johndoe@example.com",
"metadata": {
"For": "John Doe",
"Award": "Example Award",
"Date": "11/09/24",
"Signature": "JD"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0x37364655ec469e0e7d8313c61bbbcc8e208a7cdad4c3c18ac9d960bfe596f8be",
"id": "66b5bc5c499e16b433a68722"
},
{
"certificateId": "FEST/org-1234",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": "6694ff34361b2488daa17354",
"issuedDate": "2024-09-08T00:00:00.000Z",
"issuedTo": "janedoe@example.com",
"metadata": {
"For": "Jane Doe",
"Award": "Example Certificate",
"Date": "11/09/24",
"Signature": "JD"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0xa961efe8b6e43f51fee0bdf12eb735d41bed2ba30437a3ecc08834f990966198",
"id": "66b5b2f2499e16b433a685c6"
},
{
"certificateId": "FEST/New-Cert-01",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": "6694ff34361b2488daa17354",
"issuedDate": "2024-08-07T18:30:00.000Z",
"issuedTo": "example@example.com",
"metadata": {
"For": "John Smith",
"Award": "Graduation",
"Date": "22-01-2024",
"Signature": "JS"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0xe2026bbc491aa0938a3d803e591977aa692f68126a570d21c6c67cba63f914de",
"id": "66b467415e8832356a300a31"
}
]
}Usage: To retrieve a list of all certificates of the authorized organization, send a GET request to /.
GET /my
Retrieves certificates for the authenticated user.
Description: This endpoint retrieves the certificates created by the currently authenticated user.
Authentication: This route requires authentication with the 'read' permission.
Parameters: None
Response:
- Success Response:
json
{
"certificates": [
{
"certificateId": "FEST/org-123",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": "6694ff34361b2488daa17354",
"issuedDate": "2024-09-08T00:00:00.000Z",
"issuedTo": "johndoe@example.com",
"metadata": {
"For": "John Doe",
"Award": "Example Award",
"Date": "11/09/24",
"Signature": "JD"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0x37364655ec469e0e7d8313c61bbbcc8e208a7cdad4c3c18ac9d960bfe596f8be",
"id": "66b5bc5c499e16b433a68722"
},
{
"certificateId": "FEST/org-1234",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": "6694ff34361b2488daa17354",
"issuedDate": "2024-09-08T00:00:00.000Z",
"issuedTo": "janedoe@example.com",
"metadata": {
"For": "Jane Doe",
"Award": "Example Certificate",
"Date": "11/09/24",
"Signature": "JD"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0xa961efe8b6e43f51fee0bdf12eb735d41bed2ba30437a3ecc08834f990966198",
"id": "66b5b2f2499e16b433a685c6"
},
{
"certificateId": "FEST/New-Cert-01",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": "6694ff34361b2488daa17354",
"issuedDate": "2024-08-07T18:30:00.000Z",
"issuedTo": "example@example.com",
"metadata": {
"For": "John Smith",
"Award": "Graduation",
"Date": "22-01-2024",
"Signature": "JS"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0xe2026bbc491aa0938a3d803e591977aa692f68126a570d21c6c67cba63f914de",
"id": "66b467415e8832356a300a31"
}
]
}Usage: To retrieve certificates for the authenticated user, send a GET request to /my.
GET /email/:email
Retrieves certificates by email.
Description: This endpoint retrieves certificates associated with a specific email address.
Authentication: Recipient authentication required
Parameters:
email(required): The email address to retrieve certificates for.
Response:
- Success Response (200 OK):
json
{
"certificates": [
{
"certificateId": "FEST/org-12343",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": {
"organizationLogo": {
"originalImage": "https://example.com/logo.jpg",
"thumbnailImage": "https://example.com/logo-thumbnail.jpg"
},
"accessScope": [
"read",
"write",
"delete",
"create",
"update",
"user_management",
"subscription_management",
"api_key_management",
"read"
],
"acronym": "FEST",
"apiKeys": [],
"deleted": false,
"organizationName": "First Org",
"ownedBy": "6695055dbc506c59f04aad81",
"id": "6694ff34361b2488daa17354"
},
"issuedDate": "2024-09-07T18:30:00.000Z",
"issuedTo": "johndoe@example.com",
"metadata": {
"Name": "John Doe",
"Award": "Example Award"
},
"template": "66b5c377af24eea77bf5e68a",
"txnHash": "0x0b3a0568fec7da972a3392708a5d9df1978bb3e199f1d0b18912e2c2ee62d277",
"id": "66b5c458af24eea77bf5e729"
},
{
"certificateId": "FEST/org-123",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": {
"organizationLogo": {
"originalImage": "https://example.com/logo.jpg",
"thumbnailImage": "https://example.com/logo-thumbnail.jpg"
},
"accessScope": [
"read",
"write",
"delete",
"create",
"update",
"user_management",
"subscription_management",
"api_key_management",
"read"
],
"acronym": "FEST",
"apiKeys": [],
"deleted": false,
"organizationName": "First Org",
"ownedBy": "6695055dbc506c59f04aad81",
"id": "6694ff34361b2488daa17354"
},
"issuedDate": "2024-09-08T00:00:00.000Z",
"issuedTo": "johndoe@example.com",
"metadata": {
"For": "John Doe",
"Award": "Example Award",
"Date": "11/09/24",
"Signature": "JD"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0x37364655ec469e0e7d8313c61bbbcc8e208a7cdad4c3c18ac9d960bfe596f8be",
"id": "66b5bc5c499e16b433a68722"
}
]
}Validation: Email validation
Usage: To retrieve certificates by email, send a GET request to /email/:email, replacing :email with the email address you want to retrieve certificates for.
GET /checkAvailability
Checks the availability of a certificate.
Description: This endpoint checks the availability of a certificate based on the provided certificate ID. Parameters:
certificateId(query parameter): The ID of the certificate to check for availability
Example:
GET /checkAvailability?certificateId=123456
Response:
- Success Response: { "isAvailable": true }
Usage: To check the availability of a certificate, send a GET request to /checkAvailability with the certificateId as a query parameter.
GET /certificate
Retrieves a certificate by ID.
Description: This endpoint retrieves a specific certificate based on the provided certificate ID.
Authentication: No authentication required
Parameters:
certificateId(query parameter): The ID of the certificate to retrieve
Example:
GET /certificate?certificateId=123456
Response:
- Success Response:
json
{
"certificate": {
"certificateId": "FEST/org-123",
"certificateName": "certificate",
"createdBy": "6695055dbc506c59f04aad81",
"issuedBy": {
"organizationLogo": {
"originalImage": "https://certicheckv2.blob.core.windows.net/6694ff34361b2488daa17354/logo-980ada2d.jpg",
"thumbnailImage": "https://certicheckv2.blob.core.windows.net/6694ff34361b2488daa17354/logo-thumbnail-980ada2d.jpg"
},
"accessScope": [
"read",
"write",
"delete",
"create",
"update",
"user_management",
"subscription_management",
"api_key_management",
"read"
],
"acronym": "FEST",
"apiKeys": [],
"deleted": false,
"organizationName": "First Org",
"ownedBy": "6695055dbc506c59f04aad81",
"id": "6694ff34361b2488daa17354"
},
"issuedDate": "2024-09-08T00:00:00.000Z",
"issuedTo": "nayananarayanannn@gmail.com",
"metadata": {
"For": "Nayana",
"Award": "Award",
"Date": "11/09/24",
"Signature": "NN"
},
"template": "66b460de5e8832356a3008e7",
"txnHash": "0x37364655ec469e0e7d8313c61bbbcc8e208a7cdad4c3c18ac9d960bfe596f8be",
"id": "66b5bc5c499e16b433a68722"
}
}Usage: To retrieve a specific certificate, send a GET request to /certificate with the certificateId as a query parameter.
Dependencies
- Express Router
- Certificate Controller
- Authentication Middleware
- Recipient Authentication Middleware
- Validation Middleware
- Certificate Validation