Skip to content

Create a federated credential

POST
/organizations/{orgId}/service-accounts/{accountId}/federated-credentials
curl --request POST \
--url https://api.modeldesk.io/organizations/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/service-accounts/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/federated-credentials \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "issuer": "example", "repository": "example", "ref": "example", "environment": "example", "allowPullRequest": false }'

Create a federated trust rule, letting a CI workflow act as this service account by proving its own identity to an external OIDC issuer instead of presenting a stored secret. No credential material passes through this endpoint in either direction. The response carries a null repositoryId: the platform makes no call to the issuer here, and the durable repository id is captured from the first token that matches this rule by name.

orgId
required
string format: uuid
accountId
required
string format: uuid
Media typeapplication/json
object
issuer

Defaults to the GitHub Actions issuer when omitted, which is the only issuer admitted today. Any other value is rejected.

string
repository
required

The owner/repo name. Mandatory, so no rule can ever be owner-wide.

string
<= 200 characters /^[A-Za-z0-9](?:[A-Za-z0-9._-]*)/[A-Za-z0-9](?:[A-Za-z0-9._-]*)$/
ref

Optional branch or tag pin, in the full form the issuer emits (e.g. refs/heads/main); a short main is not normalized. Blank is treated as absent.

string
<= 200 characters
environment

Optional deployment-environment pin. Blank is treated as absent.

string
<= 200 characters
allowPullRequest

Omitted or null takes the safe posture: pull-request runs cannot authenticate.

boolean

Created

Media typeapplication/json

A trust rule letting a CI workflow act as a service account by proving its own identity to an external OIDC issuer, so no secret is stored on either side.

object
id
required

Also the credential identifier stamped into every token this rule mints, so a minted token is traceable back to the exact rule that admitted it.

string format: uuid
issuer
required

The external issuer whose tokens this rule accepts.

string
repository
required

The owner/repo name. The match key until repositoryId is pinned, a display label afterwards.

string
repositoryId

The issuer’s immutable repository id, and the durable match key. Absent until the first successful exchange pins it. Once pinned, a token bearing the same repository name but a different id can no longer match, which is what stops a renamed or re-registered repository name from impersonating the original; a legitimate rename keeps working, because the id is stable.

string
ref

Branch or tag pin, in the full form the issuer emits (e.g. refs/heads/main). Absent matches any branch or tag.

string
environment

Deployment-environment pin. Absent matches any environment.

string
unpinned
required

True when the rule pins neither ref nor environment, and so lets every branch of the repository authenticate as this service account: a throwaway branch then carries the same authority as the default one. Computed by the server, never stored. Permitted, but the management surface warns on it.

boolean
allowPullRequest
required

Whether pull-request runs may authenticate. False unless the rule opts in: the issuer emits tokens to pull-request runs with a refs/pull/ ref, and without this guard any rule would extend the account’s authority to any pull-request run, including runs from forks whose workflow permissions are outside this platform’s visibility.

boolean
createdAt
required
string format: date-time
createdBy
required
object
id
required
string format: uuid
name
string
revokedAt
string format: date-time
revokedBy
object
id
required
string format: uuid
name
string
lastUsedAt

Approximate: stamped best-effort and throttled, so it is a “last seen” signal rather than an exact per-exchange timestamp. Absent until the rule is first used.

string format: date-time

Example generated

{
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"issuer": "example",
"repository": "example",
"repositoryId": "example",
"ref": "example",
"environment": "example",
"unpinned": true,
"allowPullRequest": true,
"createdAt": "2026-04-15T12:00:00Z",
"createdBy": {
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"name": "example"
},
"revokedAt": "2026-04-15T12:00:00Z",
"revokedBy": {
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"name": "example"
},
"lastUsedAt": "2026-04-15T12:00:00Z"
}

Bad request: malformed repository, an issuer outside the allowlist, or the account already holds the maximum number of active trust rules.

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

The caller is not an administrator of the organization. Every operation on this surface requires it.

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

No such service account in this organization. An account that does not exist, one owned by another organization, and a deleted one are deliberately indistinguishable.

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}

Error

Media typeapplication/problem+json

An RFC 9457 problem document, always sent as application/problem+json.

object
type

Present only on a typed refusal, whose own schema requires it and fixes its value. An untyped problem omits it, which RFC 9457 defines as about:blank: the status and title are all there is to branch on.

string format: uri
title
required
string
status
required
integer
detail
required
string
instance

The path of the request that was refused. Absent when the request was refused before it reached the application’s handlers: a 401 for a missing or unusable access token, and a 403 for a service account whose scopes do not reach the route.

string
violations

Present on a 400 raised by request-body validation, and on a 422 that refuses named fields (a malformed slug or namespace prefix). Each entry names the rejected property, so a client can attach the message to the field that caused it rather than showing one error for the whole form.

Array<object>
object
property
required
string
message
required
string

Example generated

{
"type": "https://example.com",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example",
"violations": [
{
"property": "example",
"message": "example"
}
]
}