# Publish or withdraw a security advisory

> Publish a draft (state published), withdraw a published advisory (state withdrawn), or publish a withdrawn one again.

<div class="g1t-endpoint"><span class="g1t-method" data-method="post">POST</span><code>/repos/{owner}/{name}/security/advisories/{id}/state</code></div>

Publishing needs a description, tells webhooks (security_advisory.published) and the repository's watchers who chose security alerts, and makes the advisory visible to anyone who can see the repository. Admin, or a security manager.

Publishing a draft with no description is `422`. Publishing sends `security_advisory.published` to webhooks and tells the repository's watchers who chose security alerts; withdrawing (`state` `withdrawn`) sends `security_advisory.withdrawn`. A withdrawn advisory can be published again. Asking for the state it already has is `409`.

- **Authentication:** Required. Send an [access token](/reference/api/#authentication) as `Authorization: Bearer`.
- **MCP tool:** [`security`](/reference/mcp/#security) with `action` `set_advisory_state`, and the same inputs
- **Scope:** An access token needs [`security:write`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | The workspace that owns the repository. |
| `name` | string | Yes | The repository's name. |
| `id` | string | Yes | The advisory's id: adv_…, or its G1TSA-… id. |

## Body parameters

Send a JSON object. Names are `snake_case`, as in responses; the `camelCase` spelling is accepted too.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `state` | string | Yes | published to publish (or publish again), withdrawn to withdraw. One of `published`, `withdrawn`. |

## Example request

```sh
curl -X POST https://api.g1t.sh/repos/flagon-io/hello/security/advisories/adv_01kq2p9f6g7h8j9k0m1n2p3q4r/state \
  -H "Authorization: Bearer $G1T_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "state": "published"
  }'
```

## Example response

A successful request answers `200` with:

```json
{
  "id": "adv_01kq2p9f6g7h8j9k0m1n2p3q4r",
  "g1tsa_id": "G1TSA-2026-h7kd-3mqw",
  "repo_id": "rep_01kq2p9f6g7h8j9k0m1n2p3q4r",
  "repo": "flagon-io/hello",
  "title": "Path traversal in the archive reader",
  "description": "A crafted archive could write outside the directory it is extracted to.",
  "severity": "high",
  "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N",
  "cvss_score": 8.1,
  "cve_id": "CVE-2026-12345",
  "ecosystem": "npm",
  "package": "@flagon/hello",
  "affected_versions": ">= 1.2.0, < 1.4.1",
  "patched_versions": ">= 1.4.1",
  "state": "published",
  "credits": [
    "ana"
  ],
  "report_id": null,
  "created_by": "syntaqx",
  "created_at": "2026-10-06T09:14:02.118Z",
  "updated_at": "2026-10-07T15:02:40.000Z",
  "published_at": "2026-10-07T15:02:40.000Z",
  "withdrawn_at": null
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change, or a token without the scope it needs. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 409 | `conflict` | The request conflicts with the current state. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
