# health.hats.answerRequest

> Approve or decline one waiting request. Approving names the grant record the patient wrote to their health.hats.audit.log space and how long it lasts; the coordinator then grants exactly what was picked, until then. Authenticated as the patient (service auth).

- Kind: procedure
- Authority: hats.health
- Lexicon: 1
- Published by [hats.health](https://lexicon.garden/identity/did:plc:uvvhtareovj2oaregs7vsibv), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:uvvhtareovj2oaregs7vsibv/health.hats.answerRequest)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:uvvhtareovj2oaregs7vsibv/health.hats.answerRequest/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:uvvhtareovj2oaregs7vsibv/health.hats.answerRequest/analytics)

## Procedure (`health.hats.answerRequest`)

Type: procedure · POST

### Input (application/json)

- `decision` (string, required)
  - Constraints: knownValues: approve | decline
- `grant` (ref): The health.hats.provider.grant record in the patient's audit space. Required to approve.
  - Reference: `com.atproto.repo.strongRef`
- `id` (string, required): The request's id, from listRequests.
- `until` (string · datetime): When the grant ends, matching the grant's provision.period.end. Required to approve.

### Output (application/json)

- `status` (string, required)
  - Constraints: knownValues: granted | declined
- `until` (string · datetime)

### Errors

- `RequestNotPending`: No waiting request has this id: it was never made, or was already answered.
- `InvalidGrant`: The grant isn't a record in the caller's audit space, or the end time is missing, past, or more than a year away.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Approve or decline one waiting request. Approving names the grant record the patient wrote to their health.hats.audit.log space and how long it lasts; the coordinator then grants exactly what was picked, until then. Authenticated as the patient (service auth).",
      "errors": [
        {
          "description": "No waiting request has this id: it was never made, or was already answered.",
          "name": "RequestNotPending"
        },
        {
          "description": "The grant isn't a record in the caller's audit space, or the end time is missing, past, or more than a year away.",
          "name": "InvalidGrant"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "decision": {
              "knownValues": [
                "approve",
                "decline"
              ],
              "type": "string"
            },
            "grant": {
              "description": "The health.hats.provider.grant record in the patient's audit space. Required to approve.",
              "ref": "com.atproto.repo.strongRef",
              "type": "ref"
            },
            "id": {
              "description": "The request's id, from listRequests.",
              "type": "string"
            },
            "until": {
              "description": "When the grant ends, matching the grant's provision.period.end. Required to approve.",
              "format": "datetime",
              "type": "string"
            }
          },
          "required": [
            "id",
            "decision"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "status": {
              "knownValues": [
                "granted",
                "declined"
              ],
              "type": "string"
            },
            "until": {
              "format": "datetime",
              "type": "string"
            }
          },
          "required": [
            "status"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "health.hats.answerRequest",
  "lexicon": 1
}
```
