Create Certificate
Overview
Creates a new certificate and deploys it to specified environments. The certificate must be provided as a PEM-encoded file. The certificate is automatically deployed to all specified environments.
Endpoint
POST /apiops/projects/{projectName}/certificates/
Authentication
Requires a Personal API Access Token.
Header
Authorization: Bearer YOUR_TOKEN
Request
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {token} | Yes |
| Content-Type | multipart/form-data | Yes |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
Form Data
| Parameter | Type | Required | Description |
|---|---|---|---|
| certificateName | string | Yes | Certificate name (unique identifier) |
| alias | string | Yes | Certificate alias (unique per environment) |
| certificateDescription | string | Yes | Certificate description |
| environmentList | array[string] | Yes | Comma-separated list of environment names to deploy to |
| pemEncodedFile | file | Yes | PEM-encoded certificate file |
Notes
certificateNamemust be unique within the projectaliasmust be unique per environment (can be same across environments)environmentListis comma-separated (e.g., “production,staging”)pemEncodedFilemust be a valid PEM-encoded certificate file- Certificate file must not be empty
- Certificate is automatically deployed to all specified environments
PEM File Format
The certificate file should be in PEM format:
-----BEGIN CERTIFICATE-----
MIIFXTCCBEWgAwIBAgIQ...
(base64 encoded certificate content)
...
-----END CERTIFICATE-----
Response
Success Response (200 OK)
{
"success": true,
"deploymentResult": {
"success": true,
"message": "Deployment completed successfully",
"environmentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployed successfully"
},
{
"environmentName": "staging",
"success": true,
"message": "Deployed successfully"
}
]
}
}
Error Response (400 Bad Request)
{
"error": "bad_request",
"error_description": "certificateName value can not be empty!"
}
or
{
"error": "bad_request",
"error_description": "alias value can not be empty!"
}
or
{
"error": "bad_request",
"error_description": "pemEncodedFile value can not be empty!"
}
or
{
"error": "bad_request",
"error_description": "environmentList value can not be empty!"
}
or
{
"error": "bad_request",
"error_description": "Certificate (name: my-certificate) is already exist!"
}
or
{
"error": "bad_request",
"error_description": "Alias (my-cert-alias) is already used for another certificate, try changing this value!"
}
Common Causes
- Missing required form fields
- Certificate name already exists
- Alias already exists in the environment
- Invalid PEM file format
- Empty certificate file
- Environment does not exist
cURL Example
Example 1: Create Certificate with Single Environment
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/certificates/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "certificateName=my-certificate" \
-F "alias=my-cert-alias" \
-F "certificateDescription=SSL certificate for API" \
-F "environmentList=production" \
-F "pemEncodedFile=@certificate.pem"
Example 2: Create Certificate with Multiple Environments
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/certificates/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "certificateName=my-certificate" \
-F "alias=my-cert-alias" \
-F "certificateDescription=SSL certificate for API" \
-F "environmentList=production,staging,development" \
-F "pemEncodedFile=@certificate.pem"
Notes and Warnings
- Certificate Name:
- Must be unique within the project
- Cannot be changed after creation
- Alias:
- Must be unique per environment
- Same alias can be used in different environments
- Used for certificate identification in keystore
- PEM File Format:
- Certificate must be in PEM format
- File must include BEGIN and END markers
- Base64 content between markers
- Environment List:
- Comma-separated list of environment names
- All environments must exist
- Certificate is deployed to all specified environments
- Automatic Deployment:
- Certificate is automatically deployed after creation
- Deployment results are returned in the response
- Failed deployments are included in
environmentResults
- Certificate Validation:
- Certificate is validated during creation
- Invalid certificates will cause creation to fail
- Permissions:
- Requires
ROLE_MANAGE_PROXIESpermission - Requires
ROLE_DEPLOY_UNDEPLOY_PROXIESpermission for deployment - User must have access to the project and environments
- Requires
Related Documentation
- List Certificates - List all certificates
- Get Certificate - Get a specific certificate
- Update Certificate - Update a certificate