Skip to content

Create a new policy

POST /api/v1/new-policy

POST /maas/api/v1/new-policy

Creates a new MaaSAuthPolicy resource. K8s calls: CREATE /k8s/v1/maasauthpolicy

Authorization

Request body

Required.

Content type: application/json

Schema: CreatePolicyRequest

Example:

{
  "name": "team-alpha-policy",
  "modelRefs": [
    {
      "name": "llama-2-7b-chat",
      "namespace": "maas-models"
    }
  ],
  "subjects": {
    "groups": [
      {
        "name": "team-alpha"
      }
    ]
  },
  "meteringMetadata": {
    "organizationId": "org-123",
    "costCenter": "engineering"
  }
}

Responses

Status Description Response body
201 Created

Policy created successfully

MaaSAuthPolicy

application/json

400 Bad Request

Bad Request. Missing or invalid fields.

ErrorResponse

application/json

401 Unauthorized

Unauthorized

None
409 Conflict

Conflict. Policy with this name already exists.

ErrorResponse

application/json

500 Internal Server Error

Internal Server Error

ErrorResponse

application/json

Example request

curl -X POST "/maas/api/v1/new-policy" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "team-alpha-policy",
  "modelRefs": [
    {
      "name": "llama-2-7b-chat",
      "namespace": "maas-models"
    }
  ],
  "subjects": {
    "groups": [
      {
        "name": "team-alpha"
      }
    ]
  },
  "meteringMetadata": {
    "organizationId": "org-123",
    "costCenter": "engineering"
  }
}'

Example response

201 Created, application/json

{
  "name": "team-alpha-policy",
  "namespace": "maas-system",
  "phase": "Pending",
  "modelRefs": [
    {
      "name": "llama-2-7b-chat",
      "namespace": "maas-models"
    }
  ],
  "subjects": {
    "groups": [
      {
        "name": "team-alpha"
      }
    ]
  },
  "meteringMetadata": {
    "organizationId": "org-123",
    "costCenter": "engineering"
  }
}