{"meta":{"title":"构件声明的 REST API 终结点","intro":"使用 REST API 来管理工件声明。","product":"REST API","breadcrumbs":[{"href":"/zh/rest","title":"REST API"},{"href":"/zh/rest/users","title":"用户"},{"href":"/zh/rest/users/attestations","title":"证明"}],"documentType":"article"},"body":"# 构件声明的 REST API 终结点\n\n使用 REST API 来管理工件声明。\n\n> [!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## List attestations by bulk subject digests\n\n```\nPOST /users/{username}/attestations/bulk-list\n```\n\nList a collection of artifact attestations associated with any entry in a list of subject digests owned by a user.\nThe collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the attestations:read permission is required.\nPlease note: in order to offer meaningful security benefits, an attestation's signature and timestamps must be cryptographically verified, and the identity of the attestation signer must be validated. Attestations can be verified using the GitHub CLI attestation verify command. For more information, see our guide on how to use artifact attestations to establish a build's provenance.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n- **`before`** (string)\n  A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see \"Using pagination in the REST API.\"\n\n- **`after`** (string)\n  A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see \"Using pagination in the REST API.\"\n\n- **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n#### Body parameters\n\n- **`subject_digests`** (array of strings) (required)\n  List of subject digests to fetch attestations for.\n\n- **`predicate_type`** (string)\n  Optional filter for fetching attestations with a given predicate type.\nThis option accepts provenance, sbom, release, or freeform text\nfor custom predicate types.\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  https://api.github.com/users/USERNAME/attestations/bulk-list \\\n  -d '{\n  \"subject_digests\": [\n    \"sha256:abc123\",\n    \"sha512:def456\"\n  ]\n}'\n```\n\n**Response schema (Status: 200):**\n\n* `attestations_subject_digests`: object, additional properties: array or null\n* `page_info`: object:\n  * `has_next`: boolean\n  * `has_previous`: boolean\n  * `next`: string\n  * `previous`: string\n\n## Delete attestations in bulk\n\n```\nPOST /users/{username}/attestations/delete-request\n```\n\nDelete artifact attestations in bulk by either subject digests or unique ID.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n#### Body parameters\n\n- **`subject_digests`** (array of strings) (required)\n  List of subject digests associated with the artifact attestations to delete.\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **404** - Resource not found\n\n## Delete attestations by subject digest\n\n```\nDELETE /users/{username}/attestations/digest/{subject_digest}\n```\n\nDelete an artifact attestation by subject digest.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n- **`subject_digest`** (string) (required)\n  Subject Digest\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **204** - No Content\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example 1: Status Code 200\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/users/USERNAME/attestations/digest/SUBJECT_DIGEST\n```\n\n**Response schema (Status: 200):**\n\n#### Example 2: Status Code 204\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/users/USERNAME/attestations/digest/SUBJECT_DIGEST\n```\n\n**Response schema (Status: 204):**\n\n## Delete attestations by ID\n\n```\nDELETE /users/{username}/attestations/{attestation_id}\n```\n\nDelete an artifact attestation by unique ID that is associated with a repository owned by a user.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n- **`attestation_id`** (integer) (required)\n  Attestation ID\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **204** - No Content\n\n- **403** - Forbidden\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example 1: Status Code 200\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/users/USERNAME/attestations/ATTESTATION_ID\n```\n\n**Response schema (Status: 200):**\n\n#### Example 2: Status Code 204\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  https://api.github.com/users/USERNAME/attestations/ATTESTATION_ID\n```\n\n**Response schema (Status: 204):**\n\n## List attestations\n\n```\nGET /users/{username}/attestations/{subject_digest}\n```\n\nList a collection of artifact attestations with a given subject digest that are associated with repositories owned by a user.\nThe collection of attestations returned by this endpoint is filtered according to the authenticated user's permissions; if the authenticated user cannot read a repository, the attestations associated with that repository will not be included in the response. In addition, when using a fine-grained access token the attestations:read permission is required.\nPlease note: in order to offer meaningful security benefits, an attestation's signature and timestamps must be cryptographically verified, and the identity of the attestation signer must be validated. Attestations can be verified using the GitHub CLI attestation verify command. For more information, see our guide on how to use artifact attestations to establish a build's provenance.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n- **`before`** (string)\n  A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see \"Using pagination in the REST API.\"\n\n- **`after`** (string)\n  A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see \"Using pagination in the REST API.\"\n\n- **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n- **`subject_digest`** (string) (required)\n  Subject Digest\n\n- **`predicate_type`** (string)\n  Optional filter for fetching attestations with a given predicate type.\nThis option accepts provenance, sbom, release, or freeform text\nfor custom predicate types.\n\n### HTTP response status codes\n\n- **200** - OK\n\n- **201** - Created\n\n- **204** - No Content\n\n- **404** - Resource not found\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/users/USERNAME/attestations/SUBJECT_DIGEST\n```\n\n**Response schema (Status: 200):**\n\n* `attestations`: array of objects:\n  * `repository_id`: integer\n  * `bundle_url`: string\n  * `initiator`: string"}