---
title: "Set the collection access level"
method: PUT
path: "/_api/key/{keyid}/database/{dbname}/collection/{collection}"
tags: ["API Keys"]
---

# Set the collection access level

`PUT /_api/key/{keyid}/database/{dbname}/collection/{collection}`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_api/key/:keyid/database/:dbname/collection/:collection/put.ts> (a function with typed inputs; its response is checked against the schema)

Sets the collection access level for the *collection* in the database *dbname* for API key with *keyid*.

Requires a JSON object with these properties:

  - **grant**: Use "rw" to set the collection level access to *Read/Write*. Use "ro" to set the collection level access to  *Read Only*. Use "none" to set the collection level access to *No access*.

 - **collection**: Use "&#42;" to set default access level for all collections.

If access level for collection is not set default("&#42;") access level is used. If default("&#42;") access level is also not set database access level is used.

**Note**: Requires *administrator* permissions.

## Path parameters

- `keyid` string, string, required
- `dbname` string, string, required
- `collection` string, string, required

## Request body

- UserGrantCollection
  - `grant` string, required: - Use "rw" to set the collection level access to *Read/Write*. - Use "ro" to set the collection level access to *Read Only*. - Use "none" to set the collection level access to *No access*.

## Response `200`

Successfully changed access level.

- ApiKeyDbnameCollectionPutExamplesRc200
  - `code` integer: HTTP response code.
  - `error` boolean: Flag if there is an error in response. *False* for this response.
  - `_system/test1` string

## Other responses

- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `401`: Failed because you do not have administrator permissions.
- `403`: Failed because you do not have access to the server.
- `404`: Failed to find specified API key.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
