Import Truststore File
Endpoint
POST /apiops/projects/{projectName}/certificates/truststore/{environmentName}/import-file/
A truststore is a view, not a stored object
Apinizer does not store a truststore. An environment trusts whatever certificates were deployed to its workers, so "importing a truststore" means registering each certificate in the bundle for that environment. This endpoint does that loop in one call.
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 the certificates are created in |
| environmentName | string | Yes | Environment the certificates are registered for |
Form Fields
| Field | Type | Required | Description |
|---|---|---|---|
| truststoreFile | file | Yes | A ZIP of certificate files, or a single certificate file |
| namePrefix | string | No | Prepended to every created certificate name, for example partner-ca- |
Response
Success Response (200 OK)
resultList names what was registered:
{
"status": "SUCCESS",
"resultList": [
"partner-root-ca",
"partner-intermediate-ca"
],
"resultCount": 2
}
When part of the bundle could not be imported, the rest still lands and the failures are reported:
{
"status": "SUCCESS",
"resultList": [
"partner-root-ca"
],
"resultCount": 1,
"unresolvedReferences": [
"Certificate (notes) could not be imported: Could not parse certificate: empty input"
]
}
Error Response (400 Bad Request)
{
"status": "FAILURE",
"resultMessage": "Environment (Production) is not found or user does not have privilege to access it!"
}
or
{
"status": "FAILURE",
"resultMessage": "The uploaded bundle holds no certificate file!"
}
or
{
"status": "FAILURE",
"resultMessage": "No certificate in this bundle could be imported! Certificate (notes) could not be imported: ..."
}
Common Causes
- The environment does not exist or cannot be reached by the user
- The ZIP is empty
- Every entry in the bundle failed to parse as a certificate
Error Response (401 Unauthorized)
{
"status": "FAILURE",
"resultMessage": "Token is not valid!"
}
cURL Example
Example 1: Push a CA Bundle into an Environment
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/certificates/truststore/Production/import-file/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "truststoreFile=@partner-cas.zip"
Example 2: Move a Truststore Between Environments
curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/certificates/truststore/UAT/export-file/" \
-H "Authorization: Bearer YOUR_TOKEN" \
--output uat-truststore.zip
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/certificates/truststore/Production/import-file/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "truststoreFile=@uat-truststore.zip"
Example 3: Keep Imported Names Apart with a Prefix
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/certificates/truststore/Production/import-file/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-F "truststoreFile=@partner-cas.zip" \
-F "namePrefix=partner-"
Notes and Warnings
- Each entry's file name becomes the certificate name and alias, with
namePrefixin front when given. Name the files the way you want the certificates named. - One bad certificate does not abandon the rest: the bundle is imported entry by entry, and whatever failed is listed in
unresolvedReferenceswith its reason. The call only fails outright when nothing at all could be imported. - Existing certificates are updated, not duplicated: an entry whose name already exists replaces that certificate's entry for this environment and leaves its other environments untouched.
- This registers certificates in a project: they become ordinary Apinizer certificates that you can list, export and delete afterwards.
- Deploy afterwards where needed: registering is what makes the environment trust them; objects that need a deployment to take effect are not pushed to the workers by this call.
Permissions
- User must have
SECRETS+EXPORT_IMPORTpermission in the project
Related Documentation
- Export Truststore File - Capture an environment's whole truststore
- Import Certificate File - Import a single certificate into named environments
- Get Truststore Certificates - List what an environment trusts, as JSON