Skip to content

[API] Deploy certificates on Android hosts - #35156

Closed
marko-lisica wants to merge 6 commits into
docs-v4.78.0from
30876-api-docs-changes
Closed

[API] Deploy certificates on Android hosts#35156
marko-lisica wants to merge 6 commits into
docs-v4.78.0from
30876-api-docs-changes

Conversation

@marko-lisica

Copy link
Copy Markdown
Member

Added a section for adding certificates in the REST API documentation.
Comment thread docs/REST API/rest-api.md Outdated
@marko-lisica
marko-lisica marked this pull request as ready for review November 5, 2025 10:26
Comment thread docs/REST API/rest-api.md
Comment on lines +694 to +707
### Add certificate

Add certificate to deploy to the all hosts on the team. Fleet currently supports adding certificates for Android that are issued from custom [SCEP](https://en.wikipedia.org/wiki/Simple_Certificate_Enrollment_Protocol) certificate authority.

`POST /api/v1/fleet/certificates`

#### Parameters

| Name | Type | In | Description |
| -------- | ------- | ---- | ------------------------------------------- |
| name | string | body | **Required.** The name of the certificate. Name can be used as certificate alias to reference in configuration profiles. |
| team | string | query | _Available in Fleet Premium_. The team ID to add profiles to. |
| certificate_authority_id | integer | body | **Required.** The certificate authority (CA) ID to issue certificate from. Currently, only custom SCEP CA is supported. To get ID use [List certificate authorities](#list-certificate-authorities-cas). |
| subject_name | string | body |**Required** The certificate's subject name (SN). Separate subject fields by a "/". For example: "/CN=john@example.com/O=Acme Inc.". |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an end-user endpoint, but the parent ticket is exclusively targeting GitOps. I think we need a /spec endpoint in the contributor API that we can use to upload multiple certificates at once, like the "apply labels" endpoint:

### Apply labels
Adds the supplied labels to Fleet. Each label requires the `name`, and `label_membership_type` properties.
If the `label_membership_type` is set to `dynamic`, the `query` property must also be specified with the value set to a query in SQL syntax.
If the `label_membership_type` is set to `manual`, the `hosts` property must also be specified with the value set to a list of hostnames.
`POST /api/v1/fleet/spec/labels`
#### Parameters
| Name | Type | In | Description |
| ----- | ---- | ---- | ------------------------------------------------------------------------------------------------------------- |
| specs | list | path | A list of the label to apply. Each label requires the `name`, `query`, and `label_membership_type` properties |
#### Example
`POST /api/v1/fleet/spec/labels`
##### Request body
```json
{
"specs": [
{
"name": "Ubuntu",
"description": "Filters Ubuntu hosts",
"query": "SELECT 1 FROM os_version WHERE platform = 'ubuntu';",
"label_membership_type": "dynamic"
},
{
"name": "local_machine",
"description": "Includes only my local machine",
"label_membership_type": "manual",
"hosts": ["snacbook-pro.local"]
}
]
}
```

Comment thread docs/REST API/rest-api.md
Comment on lines +817 to +863
### List certificates

List certificate added to Fleet with [Add certificate](#add-certificate).

`GET /api/v1/fleet/certificates`

#### Parameters

| Name | Type | In | Description |
| ----------| ------- | ---- | -------------------------------------------------------------- |
| team | string | query | _Available in Fleet Premium_. The team ID to filter profiles. |
| page | integer | query | Page number of the results to fetch. |
| per_page | integer | query | Results per page. |

#### Example

`GET /api/v1/fleet/certificates`

##### Default response

`Status: 200`

```json
{
"certificates": [
{
"id": 1,
"name": "wifi-certificate",
"certificate_authority_id": "1",
"certificate_authority_name": "PRODUCTION_SCEP_SERVER",
"created_at": "2025-11-04T00:00:00Z",
},
{
"id": 2,
"name": "vpn-certificate",
"certificate_authority_id": "1",
"certificate_authority_name": "PRODUCTION_SCEP_SERVER",
"created_at": "2025-11-04T00:00:00Z",
}
],
"meta": {
"has_next_results": false,
"has_previous_results": false
}
}
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere in #35198? If not can we cut if for scope?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we probably need something like this for GitOps, but more likely another /spec endpoint.

Comment thread docs/REST API/rest-api.md
"created_at": "2025-11-04T00:00:00Z",
"id": 1,
"name": "wifi-certificate",
"subject_name": "/CN=$FLEET_VAR_HOST_END_USER_IDP_USERNAME/OU=$FLEET_VAR_HOST_UUID/ST=$FLEET_VAR_HOST_HARDWARE_SERIAL",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If host_uuid is included in the request, the $FLEET_VAR_* tokens should be replaced with actual values from the host.

@rachaelshaw rachaelshaw added the ~api-or-yaml-design Used for pull requests (PRs) with proposed API and YAML changes label Nov 17, 2025
@ksykulev

ksykulev commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Just to be specific, here are the ends points I made as in #35788
GET /api/latest/fleet/certificates
GET /api/latest/fleet/certificates/:id
POST /api/latest/fleet/spec/certificates
DELETE /api/latest/fleet/spec/certificates

Comment thread docs/REST API/rest-api.md

### Add certificate

Add certificate to deploy to the all hosts on the team. Fleet currently supports adding certificates for Android that are issued from custom [SCEP](https://en.wikipedia.org/wiki/Simple_Certificate_Enrollment_Protocol) certificate authority.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add certificate to deploy to the all hosts on the team. Fleet currently supports adding certificates for Android that are issued from custom [SCEP](https://en.wikipedia.org/wiki/Simple_Certificate_Enrollment_Protocol) certificate authority.
Add certificate to deploy to a host. Fleet currently supports adding certificates for Android that are issued from custom [SCEP](https://en.wikipedia.org/wiki/Simple_Certificate_Enrollment_Protocol) certificate authority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

~api-or-yaml-design Used for pull requests (PRs) with proposed API and YAML changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants