# tools.kryphocron.policy.manageAudience

> Create or update a policy.audience record in the writer's own repository. With the rkey of an existing record the record is replaced; otherwise a record is created. Membership changes apply to every post that names the audience.

- Kind: procedure
- Authority: policy.kryphocron.tools
- Lexicon: 1
- Published by [lexicons.kryphocron.tools](https://lexicon.garden/identity/did:plc:femlcrrqw5ja23dlsqc6qtgy), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:femlcrrqw5ja23dlsqc6qtgy/tools.kryphocron.policy.manageAudience)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:femlcrrqw5ja23dlsqc6qtgy/tools.kryphocron.policy.manageAudience/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:femlcrrqw5ja23dlsqc6qtgy/tools.kryphocron.policy.manageAudience/analytics)

## Procedure (`tools.kryphocron.policy.manageAudience`)

Type: procedure · POST

### Input (application/json)

- `record` (ref, required)
  - Reference: `tools.kryphocron.policy.audience`
- `repo` (string · did, required): DID of the writer's repository. Must be the authenticated account.
- `rkey` (string · record-key): Record key. Names the record to update when it exists; a TID is generated when absent.
  - Constraints: maxLength: 512
- `swapRecord` (string · cid): On update, compare and swap with the current record CID.
- `validate` (boolean): Lexicon validation preference, as for com.atproto.repo.createRecord.

### Output (application/json)

- `cid` (string · cid, required): CID of the written record.
- `uri` (string · at-uri, required)

### Errors

- `InvalidRequest`: The record is malformed.
- `Forbidden`: The caller may not write to this repository, or the host does not allow this account private-tier writes.
- `InvalidSwap`: swapRecord did not match the current record CID.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Create or update a policy.audience record in the writer's own repository. With the rkey of an existing record the record is replaced; otherwise a record is created. Membership changes apply to every post that names the audience.",
      "errors": [
        {
          "description": "The record is malformed.",
          "name": "InvalidRequest"
        },
        {
          "description": "The caller may not write to this repository, or the host does not allow this account private-tier writes.",
          "name": "Forbidden"
        },
        {
          "description": "swapRecord did not match the current record CID.",
          "name": "InvalidSwap"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "record": {
              "ref": "tools.kryphocron.policy.audience",
              "type": "ref"
            },
            "repo": {
              "description": "DID of the writer's repository. Must be the authenticated account.",
              "format": "did",
              "type": "string"
            },
            "rkey": {
              "description": "Record key. Names the record to update when it exists; a TID is generated when absent.",
              "format": "record-key",
              "maxLength": 512,
              "type": "string"
            },
            "swapRecord": {
              "description": "On update, compare and swap with the current record CID.",
              "format": "cid",
              "type": "string"
            },
            "validate": {
              "description": "Lexicon validation preference, as for com.atproto.repo.createRecord.",
              "type": "boolean"
            }
          },
          "required": [
            "repo",
            "record"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "cid": {
              "description": "CID of the written record.",
              "format": "cid",
              "type": "string"
            },
            "uri": {
              "format": "at-uri",
              "type": "string"
            }
          },
          "required": [
            "uri",
            "cid"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "tools.kryphocron.policy.manageAudience",
  "lexicon": 1
}
```
