Certificates
Certificates allow you to secure your projects with SSL/TLS encryption. Depfloy uses Let's Encrypt to automatically provision and manage SSL certificates for your domains. On this page, we will dive into the different certificate endpoints you can use to manage SSL certificates programmatically.
Certificate operations #
SSL certificates are automatically provisioned when you enable SSL for a project. The certificate endpoints allow you to manually trigger certificate creation or removal.
/api/v1/certificatesCreate a certificate #
This endpoint allows you to request a new SSL certificate for a project. The certificate is automatically provisioned using Let’s Encrypt and configured in Nginx.
Required attributes #
- project_id integer
-
The ID of the project to create the certificate for.
- domain_id integer
-
The ID of the primary domain to request the certificate for. You can fetch the domains from the
/api/v1/domainsendpoint.
curl https://app.depfloy.com/api/v1/certificates \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"project_id": 16532,
"domain_id": 136526
}'{
"status": "success",
"message": "SSL certificate requested successfully",
"data": {
"ssl_response": {
"ok": true,
"system_output": [
"[ssl] : Requesting a certificate for example.com",
"[ssl] : Successfully received certificate.",
"[ssl] : Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem",
"[ssl] : Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem",
"[ssl] : This certificate expires on 2025-04-15.",
"[ssl] : Deploying certificate",
"[ssl] : Successfully deployed certificate for example.com",
"[ssl] : Congratulations! You have successfully enabled HTTPS on https://example.com"
]
},
"nginx_response": {
"ok": true,
"system_output": [
"[nginx] : nginx: the configuration file /etc/nginx/nginx.conf syntax is ok",
"[nginx] : nginx: configuration file /etc/nginx/nginx.conf test is successful"
]
},
}
}
} /api/v1/projects/:projectId/certificatesList certificates #
This endpoint allows you to list all SSL certificates for a project by its ID.
curl https://app.depfloy.com/api/v1/projects/16532/certificates \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" [
{
"id": 136526,
"project_id": 16532,
"domain_id": 136526,
"cert_name": "example.com",
"cert_path": "/etc/letsencrypt/live/example.com/fullchain.pem",
"cert_key_path": "/etc/letsencrypt/live/example.com/privkey.pem",
"status": 1,
"expires_at": "2025-04-15"
},
// ... more certificates
]/api/v1/projects/:projectId/certificates/:certificateIdRetrieve a certificate #
This endpoint allows you to retrieve an SSL certificate for a project by its ID.
curl https://app.depfloy.com/api/v1/projects/16532/certificates/136526 \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json"{
"id": 136526,
"project_id": 16532,
"domain_id": 136526,
"cert_name": "example.com",
"cert_path": "/etc/letsencrypt/live/example.com/fullchain.pem",
"cert_key_path": "/etc/letsencrypt/live/example.com/privkey.pem",
"status": 1,
"expires_at": "2025-04-15"
}/api/v1/projects/:projectId/certificates/:certificateId/renewRenew a certificate #
This endpoint allows you to renew an SSL certificate for a project by its ID.
curl https://app.depfloy.com/api/v1/projects/16532/certificates/136526/renew \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json"{
"status": "success",
"message": "SSL certificate renewed successfully",
"data": {
"nginx_response": {
"ok": true,
"system_output": [
"[nginx] : nginx: the configuration file /etc/nginx/nginx.conf syntax is ok",
"[nginx] : nginx: configuration file /etc/nginx/nginx.conf test is successful"
]
}
}
}/api/v1/certificates/:projectIdDelete a certificate #
This endpoint allows you to delete an SSL certificate from a project. This will remove the certificate and revert the project to HTTP.
curl -X DELETE https://app.depfloy.com/api/v1/certificates/14532 \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json"{
"status": "success",
"message": "SSL certificate deleted successfully",
"data": {
"nginx_response": {
"ok": true,
"system_output": [
"[nginx] : nginx: the configuration file /etc/nginx/nginx.conf syntax is ok",
"[nginx] : nginx: configuration file /etc/nginx/nginx.conf test is successful"
]
}
}
}