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.
Create 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
- Name
project_id- Type
- integer
- Description
The ID of the project to create the certificate for.
- Name
domain_id- Type
- integer
- Description
The ID of the primary domain to request the certificate for. You can fetch the domains from the
/api/v1/domainsendpoint.
Request
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
}'
Response
{
"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"
]
},
}
}
}
List certificates
This endpoint allows you to list all SSL certificates for a project by its ID.
Request
curl https://app.depfloy.com/api/v1/projects/16532/certificates \
-H "Authorization: Bearer {API_KEY}" \
-H "Accept: application/json" \
-H "Content-Type: application/json"
Response
[
{
"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
]
Retrieve a certificate
This endpoint allows you to retrieve an SSL certificate for a project by its ID.
Request
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"
Response
{
"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"
}
Renew a certificate
This endpoint allows you to renew an SSL certificate for a project by its ID.
Request
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"
Response
{
"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"
]
}
}
}
Delete 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.
Request
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"
Response
{
"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"
]
}
}
}