# Hand a kept KVStore over to a Workflow

URL: /docs/api/services/kvstore/handover

`POST /apis/funcd.io/v1alpha1/namespaces/{namespace}/kvstores/{name}/handover`

## Authentication

One of:

- `bearer`: A credential of funcd's config, sent as Authorization: Bearer followed by its token.
- `apiKey`: A credential of funcd's config, sent in the X-Api-Key header.

## Parameters

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `namespace` | path | string, required | The store's namespace. |
| `name` | path | string, required | The store's name. |

## Body

`KVStoreHandover` as `application/json`, required.

```json
{
  "additionalProperties": false,
  "properties": {
    "workflow": {
      "description": "The Workflow that becomes the store's owner. Its spec.kv declares the store.",
      "maxLength": 63,
      "minLength": 1,
      "pattern": "^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$",
      "type": "string"
    }
  },
  "required": [
    "workflow"
  ],
  "type": "object"
}
```

## Answers

| Status | Problem type | When | What to do |
| --- | --- | --- | --- |
| 200 |  | OK |  |
| 400 | `about:blank` | The body is missing or is not JSON. | Send a JSON body. |
| 401 | `urn:funcd:problem:unauthorized` | The request carries no bearer token or API key, or one that funcd does not know. | Send a credential of funcd's config as a bearer token in the Authorization header, or in X-Api-Key. |
| 403 | `urn:funcd:problem:forbidden` | The credential's role or namespaces do not allow it to update and delete KVStores and read Workflows in the namespace. | Use a credential whose role allows it, such as a developer of the namespace or an admin. |
| 404 | `urn:funcd:problem:not-found` | No KVStore or no Workflow of those names exists in the namespace. | Check the names and the namespace. |
| 409 | `urn:funcd:problem:conflict` | The Workflow does not declare the store in its spec.kv. | Declare the store in the Workflow's spec.kv, then retry. |
| 409 | `urn:funcd:problem:conflict` | The Function, Workflow or App that made the KVStore still exists, and owns it. | Change the KVStore through that owner, or delete the owner first. |
| 413 | `urn:funcd:problem:payload-too-large` | The body is larger than 1 MiB. | Send a smaller body. |
| 415 | `about:blank` | The Content-Type of the body is not JSON. | Send the body as application/json. |
| 422 | `about:blank` | The namespace or the name in the path is not a DNS-1123 label. | Use at most 63 lowercase letters, digits and hyphens, starting and ending with a letter or a digit. |
| 422 | `about:blank` | The query holds a parameter that the operation does not take. | Send only the parameters that the operation lists. |
| 422 | `about:blank` | The body breaks the schema: a field that it does not know, of the wrong type or past its limits. | Correct the field at the location that the detail gives. |