> This page is for BaaS.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.api.corpx.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.api.corpx.com/_mcp/server.

# Register a public key on a credential

POST https://tenant.api.corpx.com/v1/backoffice/tenants/{tenantId}/credentials/{clientId}/public-keys
Content-Type: application/json

Registering a key **widens** access, so it only becomes usable after an
18h grace period (`activeFrom`). Existing keys keep working in the
meantime, so a planned rotation has no 401 window.


Reference: https://docs.api.corpx.com/baas/referencia/security/add-credential-public-key

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `tenantId` (string, required) — Tenant identifier (same value as `X-Tenant-Id`).
- `clientId` (string, required) — Credential (`client_id`) the subresource belongs to.

### Headers

- `X-Tenant-Id` (string, required) — Tenant context used for authorization and routing.
- `Idempotency-Key` (string, optional) — Optional client-generated idempotency token (recommended for safe retries).

### Body (application/json)

This endpoint expects an object.

- `publicKeyPem` (string, required) — SPKI PEM (`-----BEGIN PUBLIC KEY-----`) of an EC P-256 or RSA >= 2048 key. A private-key PEM is rejected explicitly.

## Response

### 201

Key registered, pending the grace period.

- `kid` (string, required) — SHA-256 of the public key DER, truncated to 16 bytes. Derived, so you can recompute it offline and confirm you uploaded the right key.
- `alg` (enum, required)
  - Allowed values: `ES256`, `PS256`
- `status` (enum, required)
  - Allowed values: `pending`, `active`, `retired`
- `activeFrom` (datetime, optional) — When the key becomes usable (18h after registration).
- `createdAt` (datetime, optional)
- `retiredAt` (datetime, optional, nullable)

## Errors

### 403 Forbidden Error

Requester does not have permission to perform the operation.

- `errorCode` (string, required) — Stable machine-readable code. See `ErrorCode` for the known values.
- `message` (string, required) — Human-readable explanation (pt-BR). Presentation only; may change.
- `docs` (string, optional) — Link to this code in the public error catalogue.
- `requestId` (string, optional) — Gateway request id. Quote it when contacting support.
- `details` (map from string to any, optional) — Optional machine-readable context for the specific `errorCode` (for example `kind` on `identity_verification_monthly_limit_exceeded`, `maxBytes` on `payload_too_large`, `attemptsRemaining` on `facetec_attempts_exhausted`). Keys are documented per operation; absent when the code carries no extra context.
- `partner` (ErrorResponsePartner, optional) — Raw error from the settlement bank, when the failure came from it. Diagnostic only.

### 409 Conflict Error

`public_key_limit_reached`.

- `errorCode` (string, required) — Stable machine-readable code. See `ErrorCode` for the known values.
- `message` (string, required) — Human-readable explanation (pt-BR). Presentation only; may change.
- `docs` (string, optional) — Link to this code in the public error catalogue.
- `requestId` (string, optional) — Gateway request id. Quote it when contacting support.
- `details` (map from string to any, optional) — Optional machine-readable context for the specific `errorCode` (for example `kind` on `identity_verification_monthly_limit_exceeded`, `maxBytes` on `payload_too_large`, `attemptsRemaining` on `facetec_attempts_exhausted`). Keys are documented per operation; absent when the code carries no extra context.
- `partner` (ErrorResponsePartner, optional) — Raw error from the settlement bank, when the failure came from it. Diagnostic only.

### 422 Unprocessable Entity Error

`invalid_public_key`.

- `errorCode` (string, required) — Stable machine-readable code. See `ErrorCode` for the known values.
- `message` (string, required) — Human-readable explanation (pt-BR). Presentation only; may change.
- `docs` (string, optional) — Link to this code in the public error catalogue.
- `requestId` (string, optional) — Gateway request id. Quote it when contacting support.
- `details` (map from string to any, optional) — Optional machine-readable context for the specific `errorCode` (for example `kind` on `identity_verification_monthly_limit_exceeded`, `maxBytes` on `payload_too_large`, `attemptsRemaining` on `facetec_attempts_exhausted`). Keys are documented per operation; absent when the code carries no extra context.
- `partner` (ErrorResponsePartner, optional) — Raw error from the settlement bank, when the failure came from it. Diagnostic only.

## Types

### ErrorResponsePartner

Raw error from the settlement bank, when the failure came from it. Diagnostic only.

- `code` (string, optional)
- `message` (string, optional)
- `field` (string, optional) — Field the partner pointed at, when any.

## Examples

**Request**

```json
{
  "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----"
}
```

**Response**

```json
{
  "kid": "sha256:3f9a2b1c0d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a",
  "alg": "ES256",
  "status": "pending",
  "activeFrom": "2026-02-20T08:33:39Z",
  "createdAt": "2026-02-20T08:33:39Z",
  "retiredAt": "2026-02-20T08:33:39Z"
}
```

**SDK Code**

```python Security_addCredentialPublicKey_example
import requests

url = "https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys"

payload = { "publicKeyPem": "-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...
-----END PUBLIC KEY-----" }
headers = {
    "X-Tenant-Id": "X-Tenant-Id",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Security_addCredentialPublicKey_example
const url = 'https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys';
const options = {
  method: 'POST',
  headers: {
    'X-Tenant-Id': 'X-Tenant-Id',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Security_addCredentialPublicKey_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys"

	payload := strings.NewReader("{\n  \"publicKeyPem\": \"-----BEGIN PUBLIC KEY-----\\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\\n-----END PUBLIC KEY-----\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Tenant-Id", "X-Tenant-Id")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Security_addCredentialPublicKey_example
require 'uri'
require 'net/http'

url = URI("https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Tenant-Id"] = 'X-Tenant-Id'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"publicKeyPem\": \"-----BEGIN PUBLIC KEY-----\\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\\n-----END PUBLIC KEY-----\"\n}"

response = http.request(request)
puts response.read_body
```

```java Security_addCredentialPublicKey_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys")
  .header("X-Tenant-Id", "X-Tenant-Id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"publicKeyPem\": \"-----BEGIN PUBLIC KEY-----\\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\\n-----END PUBLIC KEY-----\"\n}")
  .asString();
```

```php Security_addCredentialPublicKey_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys', [
  'body' => '{
  "publicKeyPem": "-----BEGIN PUBLIC KEY-----\\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\\n-----END PUBLIC KEY-----"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'X-Tenant-Id' => 'X-Tenant-Id',
  ],
]);

echo $response->getBody();
```

```csharp Security_addCredentialPublicKey_example
using RestSharp;

var client = new RestClient("https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Tenant-Id", "X-Tenant-Id");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"publicKeyPem\": \"-----BEGIN PUBLIC KEY-----\\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\\n-----END PUBLIC KEY-----\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Security_addCredentialPublicKey_example
import Foundation

let headers = [
  "X-Tenant-Id": "X-Tenant-Id",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["publicKeyPem": "-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...
-----END PUBLIC KEY-----"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://tenant.api.corpx.com/v1/backoffice/tenants/tenantId/credentials/clientId/public-keys")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```