> For the complete documentation index, see [llms.txt](https://docs.plock.io/plock-overview/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.plock.io/plock-overview/use-cases/for-developers/api/endpoints/usage.md).

# Usage

Usage

## GET /api/c1/product-usages

> Get all product usage

```json
{"openapi":"3.1.0","info":{"title":"Plock external API","version":"0.2.1"},"tags":[{"name":"Usage","description":"Usage"}],"servers":[{"url":"https://api.plock.io","description":"Production"},{"url":"https://test-api.plock.io","description":"Test"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"JsonApiMeta":{"properties":{"page":{"properties":{"currentPage":{"type":"integer"},"from":{"type":"integer"},"lastPage":{"type":"integer"},"perPage":{"type":"integer"},"to":{"type":"integer"},"total":{"type":"integer"}},"type":"object"}},"type":"object"},"JsonApiVersion":{"properties":{"version":{"type":"string"}},"type":"object"},"JsonApiLinks":{"properties":{"first":{"type":"string"},"last":{"type":"string"},"next":{"type":"string"}},"type":"object"},"ProductUsages":{"properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"properties":{"accountId":{"title":"accountId","description":"The account ID in Plock","type":"number"},"crmId":{"title":"crmId","description":"Your accounts CRM ID","type":"string"},"productId":{"title":"productId","description":"The product ID in Plock","type":"string"},"value":{"title":"value","description":"The value recorded","type":"number"},"timestamp":{"title":"timestamp","description":"The timestamp recorded","type":"string","format":"date"},"description":{"title":"description","description":"Optional free-text description","type":"string"}},"type":"object"},"relationships":{"properties":{}},"links":{"$ref":"#/components/schemas/JsonApiLinksSingle"}},"type":"object"},"JsonApiLinksSingle":{"properties":{"self":{"type":"string"}},"type":"object"},"JsonApiErrors":{"properties":{"detail":{"type":"string"},"status":{"type":"string"},"title":{"type":"string"}},"type":"object"}}},"paths":{"/api/c1/product-usages":{"get":{"tags":["Usage"],"summary":"Get all product usage","operationId":"getProductUsages","parameters":[{"name":"page","in":"query","description":"Pagination number and size","required":false,"style":"deepObject","explode":true,"schema":{"properties":{"size":{"description":"Number of objects returned per page","type":"integer"},"number":{"description":"Page number","type":"integer"}},"type":"object"}},{"name":"Accept","in":"header","description":"The client must specify an Accept header.","required":true,"schema":{"type":"string","enum":["application/vnd.api+json"]}},{"name":"filter","in":"query","description":"Filter to use","required":false,"style":"deepObject","explode":true,"schema":{"properties":{"accountId":{"description":"Get all usage where account ID is ..","type":"integer"},"productId":{"description":"Get all usage where product ID is ..","type":"integer"},"timestampBetween":{"description":"Get all usage where timestamp is between \"X,Y\"","type":"string","format":"date"}},"type":"object"}}],"responses":{"200":{"description":"OK","content":{"application/vnd.api+json":{"schema":{"properties":{"meta":{"$ref":"#/components/schemas/JsonApiMeta"},"jsonapi":{"$ref":"#/components/schemas/JsonApiVersion"},"links":{"$ref":"#/components/schemas/JsonApiLinks"},"data":{"type":"array","items":{"$ref":"#/components/schemas/ProductUsages"}}},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application/vnd.api+json":{"schema":{"properties":{"jsonapi":{"$ref":"#/components/schemas/JsonApiVersion"},"errors":{"type":"array","items":{"$ref":"#/components/schemas/JsonApiErrors"}}},"type":"object"}}}}}}}}}
```

## POST /api/c1/product-usages

> Add product usage

```json
{"openapi":"3.1.0","info":{"title":"Plock external API","version":"0.2.1"},"tags":[{"name":"Usage","description":"Usage"}],"servers":[{"url":"https://api.plock.io","description":"Production"},{"url":"https://test-api.plock.io","description":"Test"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"paths":{"/api/c1/product-usages":{"post":{"tags":["Usage"],"summary":"Add product usage","operationId":"addProductUsages","parameters":[{"name":"Accept","in":"header","description":"The client must specify an Accept header.","required":true,"schema":{"type":"string","enum":["application/json"]}},{"name":"Content-Type","in":"header","description":"The client must specify a Content-Type header.","required":true,"schema":{"type":"string","enum":["application/json"]}}],"requestBody":{"description":"Product usage","required":true,"content":{"application/json":{"schema":{"properties":{"ts":{"description":"UNIX timestamp of value","type":"integer"},"value":{"description":"Value recorded at ts","type":"number","format":"float"},"crm_id":{"description":"CRM ID of the account","type":"string"},"product_id":{"description":"Product ID for the product","type":"integer"}},"type":"object"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"properties":{"success":{"type":"boolean"}},"type":"object"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"properties":{"message":{"type":"string"}},"type":"object"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"properties":{"message":{"type":"string"},"errors":{"type":"array","items":{}}},"type":"object"}}}},"422":{"description":"Unprocessable content","content":{"application/json":{"schema":{"properties":{"message":{"type":"string"},"errors":{"type":"array","items":{}}},"type":"object"}}}}}}}}}
```
