# Issue a certificate

`POST https://api.cademi.com.br/api/v3/users/{user_id}/certificates`

Operation ID: `certificates.create` · API v3

Issues a certificate to the user for the specified product.

If the user already holds a valid certificate for the product, the existing certificate is returned instead of a new one being issued.

To reissue a certificate, set `supersedes_certificate_id` to the certificate being replaced. Reissuing requires the `certificates.reissue` permission in addition to `certificates.create`, and the replaced certificate is revoked with the reason `reissued`.

Required permissions: `certificates.create`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `user_id` | path | string | yes |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `product_id` | string | yes |  |
| `supersedes_certificate_id` | string or null | no |  |

## Responses

### 200

The user already holds a valid certificate for this product. Returns the existing certificate.

Body: `data`: Certificate.

Fields of Certificate:

| Field | Type | Required | Description |
|---|---|---|---|
| `code` | string | yes | Code printed on the certificate and used by public certificate validation. |
| `deleted` | boolean | yes |  |
| `fields` | object or null | no | Data captured at issuance, which does not change afterward. Requires the users.read_personal permission. |
| `id` | string | yes | Public ID of the certificate, prefixed with cer_. |
| `issued_at` | string (date-time) | yes |  |
| `number` | object | yes | Certificate numbering: the account-wide sequence and the per-product sequence. |
| `object` | string, one of `certificate` | yes |  |
| `pdf_url` | string | yes | URL of the certificate PDF, rendered from the certificate code. |
| `product_id` | string | yes | Public ID of the product, prefixed with prd_. |
| `reissue` | boolean | yes | Whether this certificate was produced by a reissue. |
| `revision` | string | yes |  |
| `revoked` | object or null | yes | Present only when the certificate has been revoked. |
| `status` | string, one of `valid`, `revoked` | yes |  |
| `superseded_by_certificate_id` | string or null | yes | Public ID of the certificate that replaced this one. |
| `supersedes_certificate_id` | string or null | yes | Public ID of the certificate that this one replaced. |
| `user_id` | string | yes | Public ID of the user, prefixed with usr_. |
| `validation_url` | string | yes | URL of the public validation page for the certificate code. |

### 201

Returns the newly issued certificate.

Body: `data`: Certificate.

Fields of Certificate:

| Field | Type | Required | Description |
|---|---|---|---|
| `code` | string | yes | Code printed on the certificate and used by public certificate validation. |
| `deleted` | boolean | yes |  |
| `fields` | object or null | no | Data captured at issuance, which does not change afterward. Requires the users.read_personal permission. |
| `id` | string | yes | Public ID of the certificate, prefixed with cer_. |
| `issued_at` | string (date-time) | yes |  |
| `number` | object | yes | Certificate numbering: the account-wide sequence and the per-product sequence. |
| `object` | string, one of `certificate` | yes |  |
| `pdf_url` | string | yes | URL of the certificate PDF, rendered from the certificate code. |
| `product_id` | string | yes | Public ID of the product, prefixed with prd_. |
| `reissue` | boolean | yes | Whether this certificate was produced by a reissue. |
| `revision` | string | yes |  |
| `revoked` | object or null | yes | Present only when the certificate has been revoked. |
| `status` | string, one of `valid`, `revoked` | yes |  |
| `superseded_by_certificate_id` | string or null | yes | Public ID of the certificate that replaced this one. |
| `supersedes_certificate_id` | string or null | yes | Public ID of the certificate that this one replaced. |
| `user_id` | string | yes | Public ID of the user, prefixed with usr_. |
| `validation_url` | string | yes | URL of the public validation page for the certificate code. |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The user, product, or superseded certificate was not found or is not accessible with the current credentials.

Body: Error.

### 409

The user is not eligible for a certificate for this product. The reason is provided in details[].reason.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

Full schema: https://cademi.dev/openapi/v3.json
