# Capacity Rules

## List capacity rules

> Retrieve list of capacity rule

```json
{"openapi":"3.0.3","info":{"title":"Collaboration","version":"v1"},"tags":[],"security":[{"user":[]},{"accessKey":[]}],"components":{"securitySchemes":{"user":{"description":"Provide the token that is returned upon login","scheme":"bearer","type":"http","bearerFormat":"jwt"},"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"parameters":{"queryLimit":{"description":"Limits the number of results to return","in":"query","name":"limit","schema":{"default":10,"maximum":100,"minimum":1,"type":"integer"}},"queryCursor":{"description":"Pagination token that keeps of track of the current position in the list","in":"query","name":"pageToken","schema":{"maxLength":8000,"type":"string"}},"queryDirection":{"description":"Order in which to retrieve the results","in":"query","name":"reverse","schema":{"default":false,"type":"boolean"}}},"schemas":{"CapacityRulesList":{"required":["results"],"properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/CapacityRule"}}}},"CapacityRule":{"type":"object","additionalProperties":false,"required":["id","workspaceId","name","description","capacity"],"properties":{"id":{"type":"string"},"workspaceId":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"default":{"type":"boolean"},"capacity":{"type":"object","additionalProperties":false,"properties":{"messaging":{"type":"integer"},"email":{"type":"integer"}}},"assignedAgentIds":{"type":"array","nullable":true,"items":{"type":"string","format":"uuid"}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}}}}},"paths":{"/workspaces/{workspaceId}/inbox/capacity":{"get":{"description":"Retrieve list of capacity rule","operationId":"listCapacityRules","parameters":[{"$ref":"#/components/parameters/queryLimit"},{"$ref":"#/components/parameters/queryCursor"},{"$ref":"#/components/parameters/queryDirection"}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CapacityRulesList"}}},"description":"OK"}},"summary":"List capacity rules","tags":["capacity_rules"]}}}}
```

## POST /workspaces/{workspaceId}/inbox/capacity

> Create Capacity Rule

```json
{"openapi":"3.0.3","info":{"title":"Collaboration","version":"v1"},"tags":[],"security":[{"user":[]},{"accessKey":[]}],"components":{"securitySchemes":{"user":{"description":"Provide the token that is returned upon login","scheme":"bearer","type":"http","bearerFormat":"jwt"},"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"schemas":{"CreateCapacityRule":{"type":"object","additionalProperties":false,"required":["name","description","capacity"],"properties":{"name":{"type":"string","minLength":1,"maxLength":255},"description":{"type":"string","minLength":1,"maxLength":255},"default":{"type":"boolean"},"capacity":{"type":"object","additionalProperties":false,"required":["messaging","email"],"properties":{"messaging":{"type":"integer"},"email":{"type":"integer"}}},"agents":{"type":"array","items":{"type":"string","format":"uuid"}}}},"CapacityRule":{"type":"object","additionalProperties":false,"required":["id","workspaceId","name","description","capacity"],"properties":{"id":{"type":"string"},"workspaceId":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"default":{"type":"boolean"},"capacity":{"type":"object","additionalProperties":false,"properties":{"messaging":{"type":"integer"},"email":{"type":"integer"}}},"assignedAgentIds":{"type":"array","nullable":true,"items":{"type":"string","format":"uuid"}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}}},"ValidationError":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","minLength":5},"message":{"type":"string","minLength":5},"details":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}}},"paths":{"/workspaces/{workspaceId}/inbox/capacity":{"post":{"operationId":"createCapacityRule","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCapacityRule"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CapacityRule"}}},"description":"Created a Capacity Rule."},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Default capacity rule already exists"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Invalid input"}},"summary":"Create Capacity Rule","tags":["capacity_rules"]}}}}
```

## GET /workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}

> Get a Capacity Rule

```json
{"openapi":"3.0.3","info":{"title":"Collaboration","version":"v1"},"tags":[],"security":[{"user":[]},{"accessKey":[]}],"components":{"securitySchemes":{"user":{"description":"Provide the token that is returned upon login","scheme":"bearer","type":"http","bearerFormat":"jwt"},"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"schemas":{"CapacityRule":{"type":"object","additionalProperties":false,"required":["id","workspaceId","name","description","capacity"],"properties":{"id":{"type":"string"},"workspaceId":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"default":{"type":"boolean"},"capacity":{"type":"object","additionalProperties":false,"properties":{"messaging":{"type":"integer"},"email":{"type":"integer"}}},"assignedAgentIds":{"type":"array","nullable":true,"items":{"type":"string","format":"uuid"}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}}},"Error":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","minLength":5},"details":{"type":"object","additionalProperties":true},"message":{"type":"string","minLength":5}}}}},"paths":{"/workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}":{"get":{"operationId":"getCapacityRule","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CapacityRule"}}},"description":"ok"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Workspace or Capacity Rule not found"}},"summary":"Get a Capacity Rule","tags":["capacity_rules"]}}}}
```

## PATCH /workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}

> Update Capacity Rule

```json
{"openapi":"3.0.3","info":{"title":"Collaboration","version":"v1"},"tags":[],"security":[{"user":[]},{"accessKey":[]}],"components":{"securitySchemes":{"user":{"description":"Provide the token that is returned upon login","scheme":"bearer","type":"http","bearerFormat":"jwt"},"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"schemas":{"UpdateCapacityRule":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string"},"description":{"type":"string"},"default":{"type":"boolean"},"capacity":{"type":"object","additionalProperties":false,"required":["messaging","email"],"properties":{"messaging":{"type":"integer"},"email":{"type":"integer"}}}}},"CapacityRule":{"type":"object","additionalProperties":false,"required":["id","workspaceId","name","description","capacity"],"properties":{"id":{"type":"string"},"workspaceId":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"default":{"type":"boolean"},"capacity":{"type":"object","additionalProperties":false,"properties":{"messaging":{"type":"integer"},"email":{"type":"integer"}}},"assignedAgentIds":{"type":"array","nullable":true,"items":{"type":"string","format":"uuid"}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}}},"Error":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","minLength":5},"details":{"type":"object","additionalProperties":true},"message":{"type":"string","minLength":5}}},"ValidationError":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","minLength":5},"message":{"type":"string","minLength":5},"details":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}}},"paths":{"/workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}":{"patch":{"operationId":"updateCapacityRule","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateCapacityRule"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CapacityRule"}}},"description":"Updated"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Workspace or queue found"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Default capacity rule already exists"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Invalid queue"}},"summary":"Update Capacity Rule","tags":["capacity_rules"]}}}}
```

## DELETE /workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}

> Delete a Capacity Rule

```json
{"openapi":"3.0.3","info":{"title":"Collaboration","version":"v1"},"tags":[],"security":[{"user":[]},{"accessKey":[]}],"components":{"securitySchemes":{"user":{"description":"Provide the token that is returned upon login","scheme":"bearer","type":"http","bearerFormat":"jwt"},"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"schemas":{"Error":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","minLength":5},"details":{"type":"object","additionalProperties":true},"message":{"type":"string","minLength":5}}}}},"paths":{"/workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}":{"delete":{"operationId":"deleteCapacityRule","responses":{"204":{"description":"OK"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Workspace or Capacity Rule not found"}},"summary":"Delete a Capacity Rule","tags":["capacity_rules"]}}}}
```

## POST /workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}/agents

> Assign Capacity Rule

```json
{"openapi":"3.0.3","info":{"title":"Collaboration","version":"v1"},"tags":[],"security":[{"user":[]},{"accessKey":[]}],"components":{"securitySchemes":{"user":{"description":"Provide the token that is returned upon login","scheme":"bearer","type":"http","bearerFormat":"jwt"},"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}},"schemas":{"AssignCapacityRule":{"type":"object","additionalProperties":false,"required":["agents"],"properties":{"agents":{"type":"array","items":{"type":"string","format":"uuid"}}}},"Error":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","minLength":5},"details":{"type":"object","additionalProperties":true},"message":{"type":"string","minLength":5}}},"ValidationError":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","minLength":5},"message":{"type":"string","minLength":5},"details":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}}}}}},"paths":{"/workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}/agents":{"post":{"operationId":"assignCapacityRule","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignCapacityRule"}}},"required":true},"responses":{"204":{"description":"Assigned a Capacity Rule."},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Workspace or Capacity Rule not found"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Invalid input"}},"summary":"Assign Capacity Rule","tags":["capacity_rules"]}}}}
```

## GET /workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}/agents

> get agents assigned to Capacity Rule

```json
{"openapi":"3.0.3","info":{"title":"Collaboration","version":"v1"},"tags":[],"security":[{"user":[]},{"accessKey":[]}],"components":{"securitySchemes":{"user":{"description":"Provide the token that is returned upon login","scheme":"bearer","type":"http","bearerFormat":"jwt"},"accessKey":{"description":"Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')","scheme":"AccessKey","type":"http"}}},"paths":{"/workspaces/{workspaceId}/inbox/capacity/{capacityRuleId}/agents":{"get":{"operationId":"listAgentsAssignedCapacityRule","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"agents":{"items":{"format":"uuid","type":"string"},"type":"array"}},"type":"object"}}},"description":"Successful operation"}},"summary":"get agents assigned to Capacity Rule","tags":["capacity_rules"]}}}}
```
