用户组与访问授权

维护用户组、组成员和访问授权;写操作需要 `full` 令牌。 本页完整列出 14 个受支持操作的请求与响应契约。

路径均相对于 https://<nsd-host>。先设置 NSD_BASE_URL=https://<nsd-host>/api/v1 和 NSD_TOKEN;示例 ID 与数据均为虚构值。

列出用户组

GET/api/v1/groupsread-only / full

参数

名称位置类型必填说明
cursorquerystring | null否Opaque cursor — the last id of the previous page. Absent on page 1.
limitqueryinteger | null否Requested page size; clamped to 1..=MAX_LIMIT.

请求示例

curl --silent --show-error --fail-with-body -X GET \
  "$NSD_BASE_URL/groups?limit=100" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
200Paginated list of groups in the caller's realmListGroupsResponse
401缺少或无效的 Bearer 令牌。ProblemDetails

200 响应

字段类型必有说明
itemsarray<GroupView>是Groups in this page.
items[].auto_membersstring | null否Automatic membership rule for system groups, or null.
items[].created_atstring是Creation timestamp (RFC 3339 UTC).
items[].created_bystring是Actor label that created the group.
items[].descriptionstring | null否Optional description.
items[].idstring是Group ULID.
items[].kindstring是Group kind (static or system).
items[].member_countinteger是Effective member count.
items[].namestring是Display name.
items[].realm_idstring是Owning realm ULID.
items[].slugstring是URL-safe slug.
next_cursorstring | null否Cursor for the next page, or null when there is no next page.
{
  "items": [
    {
      "auto_members": "example",
      "created_at": "2026-09-09T10:00:00Z",
      "created_by": "example",
      "description": "用于生产自动化",
      "id": "01K4EXAMPLE0000000000000",
      "kind": "static",
      "member_count": 1,
      "name": "示例资源",
      "realm_id": "01K4EXAMPLE0000000000000",
      "slug": "example"
    }
  ],
  "next_cursor": "example"
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

创建用户组

POST/api/v1/groupsfull

请求体

字段类型必填说明
descriptionstring | null否Optional description.
namestring是Display name.
request.json
{
  "description": "用于生产自动化",
  "name": "示例资源"
}

请求示例

curl --silent --show-error --fail-with-body -X POST \
  "$NSD_BASE_URL/groups" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data @request.json

响应状态

状态含义响应结构
201用户组已创建。GroupView
401缺少或无效的 Bearer 令牌。ProblemDetails

201 响应

字段类型必有说明
auto_membersstring | null否Automatic membership rule for system groups, or null.
created_atstring是Creation timestamp (RFC 3339 UTC).
created_bystring是Actor label that created the group.
descriptionstring | null否Optional description.
idstring是Group ULID.
kindstring是Group kind (static or system).
member_countinteger是Effective member count.
namestring是Display name.
realm_idstring是Owning realm ULID.
slugstring是URL-safe slug.
{
  "auto_members": "example",
  "created_at": "2026-09-09T10:00:00Z",
  "created_by": "example",
  "description": "用于生产自动化",
  "id": "01K4EXAMPLE0000000000000",
  "kind": "static",
  "member_count": 1,
  "name": "示例资源",
  "realm_id": "01K4EXAMPLE0000000000000",
  "slug": "example"
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

读取用户组

GET/api/v1/groups/{id}read-only / full

参数

名称位置类型必填说明
idpathstring是Group ULID

请求示例

curl --silent --show-error --fail-with-body -X GET \
  "$NSD_BASE_URL/groups/${GROUP_ID}" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
200The group with member countGroupView
401缺少或无效的 Bearer 令牌。ProblemDetails
404当前 Network 中不存在该用户组。ProblemDetails

200 响应

字段类型必有说明
auto_membersstring | null否Automatic membership rule for system groups, or null.
created_atstring是Creation timestamp (RFC 3339 UTC).
created_bystring是Actor label that created the group.
descriptionstring | null否Optional description.
idstring是Group ULID.
kindstring是Group kind (static or system).
member_countinteger是Effective member count.
namestring是Display name.
realm_idstring是Owning realm ULID.
slugstring是URL-safe slug.
{
  "auto_members": "example",
  "created_at": "2026-09-09T10:00:00Z",
  "created_by": "example",
  "description": "用于生产自动化",
  "id": "01K4EXAMPLE0000000000000",
  "kind": "static",
  "member_count": 1,
  "name": "示例资源",
  "realm_id": "01K4EXAMPLE0000000000000",
  "slug": "example"
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

修改用户组

PATCH/api/v1/groups/{id}full

参数

名称位置类型必填说明
idpathstring是Group ULID

请求体

字段类型必填说明
descriptionstring | null否New description, or null to clear.
namestring | null否New display name.
request.json
{
  "description": "用于生产自动化",
  "name": "示例资源"
}

请求示例

curl --silent --show-error --fail-with-body -X PATCH \
  "$NSD_BASE_URL/groups/${GROUP_ID}" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data @request.json

响应状态

状态含义响应结构
200用户组已更新。GroupView
401缺少或无效的 Bearer 令牌。ProblemDetails
403系统用户组为只读,不能修改。ProblemDetails
404当前 Network 中不存在该用户组。ProblemDetails

200 响应

字段类型必有说明
auto_membersstring | null否Automatic membership rule for system groups, or null.
created_atstring是Creation timestamp (RFC 3339 UTC).
created_bystring是Actor label that created the group.
descriptionstring | null否Optional description.
idstring是Group ULID.
kindstring是Group kind (static or system).
member_countinteger是Effective member count.
namestring是Display name.
realm_idstring是Owning realm ULID.
slugstring是URL-safe slug.
{
  "auto_members": "example",
  "created_at": "2026-09-09T10:00:00Z",
  "created_by": "example",
  "description": "用于生产自动化",
  "id": "01K4EXAMPLE0000000000000",
  "kind": "static",
  "member_count": 1,
  "name": "示例资源",
  "realm_id": "01K4EXAMPLE0000000000000",
  "slug": "example"
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

删除用户组

DELETE/api/v1/groups/{id}full

参数

名称位置类型必填说明
idpathstring是Group ULID

请求示例

curl --silent --show-error --fail-with-body -X DELETE \
  "$NSD_BASE_URL/groups/${GROUP_ID}" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
204用户组已删除。—
401缺少或无效的 Bearer 令牌。ProblemDetails
403系统用户组为只读,不能修改。ProblemDetails
404当前 Network 中不存在该用户组。ProblemDetails

204 响应

成功,无响应体。

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

列出组成员

GET/api/v1/groups/{id}/membersread-only / full

参数

名称位置类型必填说明
idpathstring是Group ULID

请求示例

curl --silent --show-error --fail-with-body -X GET \
  "$NSD_BASE_URL/groups/${GROUP_ID}/members" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
200The group's member usersarray<AdminUserView>
401缺少或无效的 Bearer 令牌。ProblemDetails
404当前 Network 中不存在该用户组。ProblemDetails

200 响应

字段类型必有说明
[].created_atstring是Creation timestamp (RFC 3339 UTC).
[].disabledboolean是Whether the user is disabled.
[].emailstring是Email address.
[].idstring是User ULID.
[].last_login_atstring | null否Last login timestamp (RFC 3339 UTC), or null.
[].mfa_enabledboolean是Whether MFA is enabled.
[].namestring是Display name.
[].realm_idstring是Owning realm ULID.
[].rolestring是Role (admin or member).
[
  {
    "created_at": "2026-09-09T10:00:00Z",
    "disabled": false,
    "email": "operator@example.com",
    "id": "01K4EXAMPLE0000000000000",
    "last_login_at": "2026-09-09T10:00:00Z",
    "mfa_enabled": false,
    "name": "示例资源",
    "realm_id": "01K4EXAMPLE0000000000000",
    "role": "admin"
  }
]

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

添加组成员

POST/api/v1/groups/{id}/membersfull

参数

名称位置类型必填说明
idpathstring是Group ULID

请求体

字段类型必填说明
user_idstring是User ULID to add.
request.json
{
  "user_id": "01K4USER000000000000000000"
}

请求示例

curl --silent --show-error --fail-with-body -X POST \
  "$NSD_BASE_URL/groups/${GROUP_ID}/members" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data @request.json

响应状态

状态含义响应结构
200Member added; returns the updated member listarray<AdminUserView>
400Missing user_id, or user is not in this realmProblemDetails
401缺少或无效的 Bearer 令牌。ProblemDetails
403系统用户组为只读,不能修改。ProblemDetails
404当前 Network 中不存在该用户组。ProblemDetails

200 响应

字段类型必有说明
[].created_atstring是Creation timestamp (RFC 3339 UTC).
[].disabledboolean是Whether the user is disabled.
[].emailstring是Email address.
[].idstring是User ULID.
[].last_login_atstring | null否Last login timestamp (RFC 3339 UTC), or null.
[].mfa_enabledboolean是Whether MFA is enabled.
[].namestring是Display name.
[].realm_idstring是Owning realm ULID.
[].rolestring是Role (admin or member).
[
  {
    "created_at": "2026-09-09T10:00:00Z",
    "disabled": false,
    "email": "operator@example.com",
    "id": "01K4EXAMPLE0000000000000",
    "last_login_at": "2026-09-09T10:00:00Z",
    "mfa_enabled": false,
    "name": "示例资源",
    "realm_id": "01K4EXAMPLE0000000000000",
    "role": "admin"
  }
]

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

移除组成员

DELETE/api/v1/groups/{id}/members/{user_id}full

参数

名称位置类型必填说明
idpathstring是Group ULID
user_idpathstring是User ULID to remove

请求示例

curl --silent --show-error --fail-with-body -X DELETE \
  "$NSD_BASE_URL/groups/${GROUP_ID}/members/${USER_ID}" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
204组成员已移除。—
401缺少或无效的 Bearer 令牌。ProblemDetails
403系统用户组为只读,不能修改。ProblemDetails
404当前 Network 中不存在该用户组。ProblemDetails

204 响应

成功,无响应体。

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

列出访问授权

GET/api/v1/policiesread-only / full

参数

名称位置类型必填说明
cursorquerystring | null否Cursor pagination: last policy id returned by the previous page.
limitqueryinteger | null否Requested page size (clamped by the shared pagination contract).
qquerystring | null否Case-insensitive literal substring search over policy name and stable id.

请求示例

curl --silent --show-error --fail-with-body -X GET \
  "$NSD_BASE_URL/policies?limit=100" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
200Paginated list of policies in the caller's realmListPoliciesResponse
400Search query exceeds 128 charactersProblemDetails
401缺少或无效的 Bearer 令牌。ProblemDetails

200 响应

字段类型必有说明
itemsarray<PolicyView>是Policies in this page.
items[].actionstring是Effect (currently always allow).
items[].compile_errorstring | null否Why the Grant is dropped. Absent while compile_status is compiled.
items[].compile_error_codestring | null否Stable token naming the same rejection as compile_error, for alerting that must not depend on wording. Absent while compile_status is compiled.
items[].compile_statusPolicyCompileStatusView是Whether the grant can take effect. A rejected grant does not allow access even when enabled is true; inspect compile_error and compile_error_code.
items[].conditionsobject是Free-form conditions object.
items[].created_atstring是Creation time (RFC 3339 UTC).
items[].created_bystring是Label of the actor who created it.
items[].enabledboolean是Whether the policy is active.
items[].enforced_atstring是Enforcement point (node | gateway).
items[].idstring是Policy ULID.
items[].namestring是Display name.
items[].realm_idstring是Owning realm ULID.
items[].resourceobject是What the policy grants access to ({ type, … }).
items[].subjectobject是Who the policy applies to ({ type, … }).
items[].versioninteger是Monotonic version, bumped on each update.
next_cursorstring | null否Cursor for the next page, or null when there is no next page.
{
  "items": [
    {
      "action": "allow",
      "compile_error": "example",
      "compile_error_code": "example",
      "compile_status": {},
      "conditions": {},
      "created_at": "2026-09-09T10:00:00Z",
      "created_by": "example",
      "enabled": true,
      "enforced_at": "2026-09-09T10:00:00Z",
      "id": "01K4EXAMPLE0000000000000",
      "name": "示例资源",
      "realm_id": "01K4EXAMPLE0000000000000",
      "resource": {
        "type": "service",
        "service_id": "01K4SERVICE00000000000000"
      },
      "subject": {
        "type": "user",
        "user_id": "01K4USER000000000000000000"
      },
      "version": 1
    }
  ],
  "next_cursor": "example"
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

创建访问授权

POST/api/v1/policiesfull

请求体

字段类型必填说明
conditionsobject否Free-form conditions object.
enabledboolean | null否Whether the policy starts enabled (defaults to true).
enforced_atstring | null否Deprecated compatibility hint. NSD derives the enforcement point from the policy subject and rejects a conflicting value.
namestring是Display name.
resourceobject否Resource object { type, … } (defaults to "Everything").
subjectobject否Subject object { type, … } (defaults to "Everyone").
request.json
{
  "conditions": {},
  "enabled": true,
  "enforced_at": "2026-09-09T10:00:00Z",
  "name": "示例资源",
  "resource": {
    "type": "service",
    "service_id": "01K4SERVICE00000000000000"
  },
  "subject": {
    "type": "user",
    "user_id": "01K4USER000000000000000000"
  }
}

请求示例

curl --silent --show-error --fail-with-body -X POST \
  "$NSD_BASE_URL/policies" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data @request.json

响应状态

状态含义响应结构
201Created policy with distribution summaryPolicyMutationResponse
400主体无效,或主体/资源不属于当前 Network。ProblemDetails
401缺少或无效的 Bearer 令牌。ProblemDetails
409OIDC 提供方与同一公网入口上的另一条访问授权冲突。ProblemDetails

201 响应

字段类型必有说明
distributionDistributionSummary是Config-distribution summary for the realm.
distribution.failedinteger是Distribution failures (always 0 in the in-process path today).
distribution.gatewaysinteger是Gateways in the realm config was (re)distributed to.
distribution.sitesinteger是Sites in the realm.
policyPolicyView是The created/updated policy.
policy.actionstring是Effect (currently always allow).
policy.compile_errorstring | null否Why the Grant is dropped. Absent while compile_status is compiled.
policy.compile_error_codestring | null否Stable token naming the same rejection as compile_error, for alerting that must not depend on wording. Absent while compile_status is compiled.
policy.compile_statusPolicyCompileStatusView是Whether the grant can take effect. A rejected grant does not allow access even when enabled is true; inspect compile_error and compile_error_code.
policy.conditionsobject是Free-form conditions object.
policy.created_atstring是Creation time (RFC 3339 UTC).
policy.created_bystring是Label of the actor who created it.
policy.enabledboolean是Whether the policy is active.
policy.enforced_atstring是Enforcement point (node | gateway).
policy.idstring是Policy ULID.
policy.namestring是Display name.
policy.realm_idstring是Owning realm ULID.
policy.resourceobject是What the policy grants access to ({ type, … }).
policy.subjectobject是Who the policy applies to ({ type, … }).
policy.versioninteger是Monotonic version, bumped on each update.
{
  "distribution": {
    "failed": 1,
    "gateways": 1,
    "sites": 1
  },
  "policy": {
    "action": "allow",
    "compile_error": "example",
    "compile_error_code": "example",
    "compile_status": "compiled",
    "conditions": {},
    "created_at": "2026-09-09T10:00:00Z",
    "created_by": "example",
    "enabled": true,
    "enforced_at": "2026-09-09T10:00:00Z",
    "id": "01K4EXAMPLE0000000000000",
    "name": "示例资源",
    "realm_id": "01K4EXAMPLE0000000000000",
    "resource": {
      "type": "service",
      "service_id": "01K4SERVICE00000000000000"
    },
    "subject": {
      "type": "user",
      "user_id": "01K4USER000000000000000000"
    },
    "version": 1
  }
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

批量创建访问授权

POST/api/v1/policies/batchfull

请求体

字段类型必填说明
policiesarray<CreatePolicyRequest>是Complete policy rows to create (2–100).
policies[].conditionsobject否Free-form conditions object.
policies[].enabledboolean | null否Whether the policy starts enabled (defaults to true).
policies[].enforced_atstring | null否Deprecated compatibility hint. NSD derives the enforcement point from the policy subject and rejects a conflicting value.
policies[].namestring是Display name.
policies[].resourceobject否Resource object { type, … } (defaults to "Everything").
policies[].subjectobject否Subject object { type, … } (defaults to "Everyone").
request.json
{
  "policies": [
    {
      "conditions": {},
      "enabled": true,
      "enforced_at": "2026-09-09T10:00:00Z",
      "name": "示例资源",
      "resource": {
        "type": "service",
        "service_id": "01K4SERVICE00000000000000"
      },
      "subject": {
        "type": "user",
        "user_id": "01K4USER000000000000000000"
      }
    }
  ]
}

请求示例

curl --silent --show-error --fail-with-body -X POST \
  "$NSD_BASE_URL/policies/batch" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data @request.json

响应状态

状态含义响应结构
201Created policies with one distribution updatePolicyBatchMutationResponse
400批次或其中的访问授权无效。ProblemDetails
401缺少或无效的 Bearer 令牌。ProblemDetails
409启用访问授权审批时不能批量创建。ProblemDetails

201 响应

字段类型必有说明
distributionDistributionSummary是Config-distribution summary for the realm.
distribution.failedinteger是Distribution failures (always 0 in the in-process path today).
distribution.gatewaysinteger是Gateways in the realm config was (re)distributed to.
distribution.sitesinteger是Sites in the realm.
policiesarray<PolicyView>是Policies created by the transaction.
policies[].actionstring是Effect (currently always allow).
policies[].compile_errorstring | null否Why the Grant is dropped. Absent while compile_status is compiled.
policies[].compile_error_codestring | null否Stable token naming the same rejection as compile_error, for alerting that must not depend on wording. Absent while compile_status is compiled.
policies[].compile_statusPolicyCompileStatusView是Whether the grant can take effect. A rejected grant does not allow access even when enabled is true; inspect compile_error and compile_error_code.
policies[].conditionsobject是Free-form conditions object.
policies[].created_atstring是Creation time (RFC 3339 UTC).
policies[].created_bystring是Label of the actor who created it.
policies[].enabledboolean是Whether the policy is active.
policies[].enforced_atstring是Enforcement point (node | gateway).
policies[].idstring是Policy ULID.
policies[].namestring是Display name.
policies[].realm_idstring是Owning realm ULID.
policies[].resourceobject是What the policy grants access to ({ type, … }).
policies[].subjectobject是Who the policy applies to ({ type, … }).
policies[].versioninteger是Monotonic version, bumped on each update.
{
  "distribution": {
    "failed": 1,
    "gateways": 1,
    "sites": 1
  },
  "policies": [
    {
      "action": "allow",
      "compile_error": "example",
      "compile_error_code": "example",
      "compile_status": {},
      "conditions": {},
      "created_at": "2026-09-09T10:00:00Z",
      "created_by": "example",
      "enabled": true,
      "enforced_at": "2026-09-09T10:00:00Z",
      "id": "01K4EXAMPLE0000000000000",
      "name": "示例资源",
      "realm_id": "01K4EXAMPLE0000000000000",
      "resource": {
        "type": "service",
        "service_id": "01K4SERVICE00000000000000"
      },
      "subject": {
        "type": "user",
        "user_id": "01K4USER000000000000000000"
      },
      "version": 1
    }
  ]
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

读取访问授权

GET/api/v1/policies/{id}read-only / full

参数

名称位置类型必填说明
idpathstring是Policy ULID

请求示例

curl --silent --show-error --fail-with-body -X GET \
  "$NSD_BASE_URL/policies/${POLICY_ID}" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
200The policyPolicyView
401缺少或无效的 Bearer 令牌。ProblemDetails
404当前 Network 中不存在该访问授权。ProblemDetails

200 响应

字段类型必有说明
actionstring是Effect (currently always allow).
compile_errorstring | null否Why the Grant is dropped. Absent while compile_status is compiled.
compile_error_codestring | null否Stable token naming the same rejection as compile_error, for alerting that must not depend on wording. Absent while compile_status is compiled.
compile_statusPolicyCompileStatusView是Whether the grant can take effect. A rejected grant does not allow access even when enabled is true; inspect compile_error and compile_error_code.
conditionsobject是Free-form conditions object.
created_atstring是Creation time (RFC 3339 UTC).
created_bystring是Label of the actor who created it.
enabledboolean是Whether the policy is active.
enforced_atstring是Enforcement point (node | gateway).
idstring是Policy ULID.
namestring是Display name.
realm_idstring是Owning realm ULID.
resourceobject是What the policy grants access to ({ type, … }).
subjectobject是Who the policy applies to ({ type, … }).
versioninteger是Monotonic version, bumped on each update.
{
  "action": "allow",
  "compile_error": "example",
  "compile_error_code": "example",
  "compile_status": "compiled",
  "conditions": {},
  "created_at": "2026-09-09T10:00:00Z",
  "created_by": "example",
  "enabled": true,
  "enforced_at": "2026-09-09T10:00:00Z",
  "id": "01K4EXAMPLE0000000000000",
  "name": "示例资源",
  "realm_id": "01K4EXAMPLE0000000000000",
  "resource": {
    "type": "service",
    "service_id": "01K4SERVICE00000000000000"
  },
  "subject": {
    "type": "user",
    "user_id": "01K4USER000000000000000000"
  },
  "version": 1
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

修改访问授权

PATCH/api/v1/policies/{id}full

参数

名称位置类型必填说明
idpathstring是Policy ULID

请求体

字段类型必填说明
conditionsobject否New conditions object.
enabledboolean | null否Enable/disable the policy.
enforced_atstring | null否Deprecated compatibility hint. NSD preserves an unchanged legacy policy shape or derives the enforcement point after a shape change.
namestring | null否New display name.
resourceobject否New resource object.
subjectobject否New subject object.
request.json
{
  "conditions": {},
  "enabled": true,
  "enforced_at": "2026-09-09T10:00:00Z",
  "name": "示例资源",
  "resource": {
    "type": "service",
    "service_id": "01K4SERVICE00000000000000"
  },
  "subject": {
    "type": "user",
    "user_id": "01K4USER000000000000000000"
  }
}

请求示例

curl --silent --show-error --fail-with-body -X PATCH \
  "$NSD_BASE_URL/policies/${POLICY_ID}" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data @request.json

响应状态

状态含义响应结构
200Updated policy with distribution summaryPolicyMutationResponse
400主体无效,或主体/资源不属于当前 Network。ProblemDetails
401缺少或无效的 Bearer 令牌。ProblemDetails
404当前 Network 中不存在该访问授权。ProblemDetails
409OIDC 提供方与同一公网入口上的另一条访问授权冲突。ProblemDetails

200 响应

字段类型必有说明
distributionDistributionSummary是Config-distribution summary for the realm.
distribution.failedinteger是Distribution failures (always 0 in the in-process path today).
distribution.gatewaysinteger是Gateways in the realm config was (re)distributed to.
distribution.sitesinteger是Sites in the realm.
policyPolicyView是The created/updated policy.
policy.actionstring是Effect (currently always allow).
policy.compile_errorstring | null否Why the Grant is dropped. Absent while compile_status is compiled.
policy.compile_error_codestring | null否Stable token naming the same rejection as compile_error, for alerting that must not depend on wording. Absent while compile_status is compiled.
policy.compile_statusPolicyCompileStatusView是Whether the grant can take effect. A rejected grant does not allow access even when enabled is true; inspect compile_error and compile_error_code.
policy.conditionsobject是Free-form conditions object.
policy.created_atstring是Creation time (RFC 3339 UTC).
policy.created_bystring是Label of the actor who created it.
policy.enabledboolean是Whether the policy is active.
policy.enforced_atstring是Enforcement point (node | gateway).
policy.idstring是Policy ULID.
policy.namestring是Display name.
policy.realm_idstring是Owning realm ULID.
policy.resourceobject是What the policy grants access to ({ type, … }).
policy.subjectobject是Who the policy applies to ({ type, … }).
policy.versioninteger是Monotonic version, bumped on each update.
{
  "distribution": {
    "failed": 1,
    "gateways": 1,
    "sites": 1
  },
  "policy": {
    "action": "allow",
    "compile_error": "example",
    "compile_error_code": "example",
    "compile_status": "compiled",
    "conditions": {},
    "created_at": "2026-09-09T10:00:00Z",
    "created_by": "example",
    "enabled": true,
    "enforced_at": "2026-09-09T10:00:00Z",
    "id": "01K4EXAMPLE0000000000000",
    "name": "示例资源",
    "realm_id": "01K4EXAMPLE0000000000000",
    "resource": {
      "type": "service",
      "service_id": "01K4SERVICE00000000000000"
    },
    "subject": {
      "type": "user",
      "user_id": "01K4USER000000000000000000"
    },
    "version": 1
  }
}

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

删除访问授权

DELETE/api/v1/policies/{id}full

参数

名称位置类型必填说明
idpathstring是Policy ULID

请求示例

curl --silent --show-error --fail-with-body -X DELETE \
  "$NSD_BASE_URL/policies/${POLICY_ID}" \
  -H "Authorization: Bearer $NSD_TOKEN" \
  -H 'Accept: application/json'

响应状态

状态含义响应结构
204Policy deleted—
401缺少或无效的 Bearer 令牌。ProblemDetails
404当前 Network 中不存在该访问授权。ProblemDetails

204 响应

成功,无响应体。

错误响应均使用 Problem Details;调用方应判断 HTTP 状态和稳定的 code,不要解析 detail 文案。

返回 API 参考总览。