{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/forge/json-schema/forge-resource-credential-schema.json",
  "title": "ResourceCredential",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/forge-openapi.yaml#/components/schemas/ResourceCredential",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "organizationId",
    "resourceId",
    "name",
    "kind",
    "default",
    "assignedTo",
    "managementMode",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "organizationId": {
      "type": "string"
    },
    "resourceId": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "kind": {
      "$ref": "#/$defs/ResourceCredentialKind"
    },
    "username": {
      "type": "string"
    },
    "headerName": {
      "type": "string"
    },
    "authentication": {
      "$ref": "#/$defs/ResourceCredentialAuthentication"
    },
    "default": {
      "type": "boolean"
    },
    "assignedTo": {
      "$ref": "#/$defs/ResourceCredentialAssignments"
    },
    "managementMode": {
      "type": "string",
      "enum": [
        "forge",
        "terraform"
      ]
    },
    "managerId": {
      "type": "string"
    },
    "managerInstance": {
      "type": "string"
    },
    "lastUsedAt": {
      "type": "string",
      "format": "date-time"
    },
    "rotatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "ResourceCredentialAssignments": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "users": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 256
        },
        "groups": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 256
        },
        "serviceAccounts": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 256
        }
      }
    },
    "ResourceCredentialAuthentication": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "region": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32
        },
        "roleArn": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        },
        "tokenEndpoint": {
          "type": "string",
          "format": "uri",
          "minLength": 1,
          "maxLength": 2048
        },
        "clientId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "scopes": {
          "type": "array",
          "uniqueItems": true,
          "maxItems": 64,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "audience": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048
        }
      }
    },
    "ResourceCredentialKind": {
      "type": "string",
      "enum": [
        "none",
        "username_password",
        "bearer_token",
        "header",
        "aws_rds_iam",
        "oauth2_client_credentials",
        "oauth2_token_exchange"
      ]
    }
  }
}