# Billing

Manage your billing.

## Retrieve tenant billing configurations.

> Retrieve details of tenant billing configurations.<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/tenant/billing":{"get":{"tags":["Billing"],"operationId":"getTenantBillingConfigurations","summary":"Retrieve tenant billing configurations.","description":"Retrieve details of tenant billing configurations.\n","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean","default":false,"description":"Enable call billing or not.\n"},"account":{"type":"string","enum":["TENANT","USER"],"default":"TENANT","description":"The billing account:  \nCan be either:  \n- `TENANT`: Use company account for billing.\n- `USER`: Use private user account for billing.\n"},"type":{"type":"string","enum":["OFFLINE","ONLINE"],"default":"OFFLINE","description":"The billing type:  \nCan be either:  \n- `OFFLINE`: Use offline charging for billing.\n- `ONLINE`: Use online charging for billing.\n"}}}}}},"4XX":{"description":"Error"}}}}}}
```

## Update tenant billing configurations.

> Update tenant billing configurations.<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/tenant/billing":{"post":{"tags":["Billing"],"operationId":"setTenantBillingConfigurations","summary":"Update tenant billing configurations.","description":"Update tenant billing configurations.\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean","default":false,"description":"Enable call billing or not.\n"},"account":{"type":"string","enum":["TENANT","USER"],"default":"TENANT","description":"The billing account:  \nCan be either:  \n- `TENANT`: Use company account for billing.\n- `USER`: Use private user account for billing.\n"},"type":{"type":"string","enum":["OFFLINE","ONLINE"],"default":"OFFLINE","description":"The billing type:  \nCan be either:  \n- `OFFLINE`: Use offline charging for billing.\n- `ONLINE`: Use online charging for billing.\n"}}}}}},"responses":{"200":{"description":"OK"},"4XX":{"description":"Error"}}}}}}
```

## List call rates

> Retrieve a collection of call rates<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/call_rates":{"get":{"tags":["Billing"],"operationId":"listCallRates","summary":"List call rates","description":"Retrieve a collection of call rates\n","parameters":[{"name":"filter","in":"query","schema":{"type":"string"},"description":"Use the `filter` query parameter to retrieve just a subset of a collection.\n"},{"name":"search","in":"query","schema":{"type":"string"},"description":"Use the `search` query parameter to restrict the results of a request to match a search criterion.\n"},{"name":"orderby","in":"query","schema":{"type":"string"},"description":"Use the `orderby` query parameter to specify the sort order of the items returned from server.  \nThe default order is ascending order.\n"},{"name":"skip","in":"query","schema":{"type":"integer","format":"int32","minimum":0,"default":0},"description":"Use the `skip` query parameter to set the number of items to skip at the start of a collection.\n"},{"name":"top","in":"query","schema":{"type":"integer","format":"int32","minimum":1,"maximum":100,"default":100},"description":"Use the `top` query parameter to specify the page size of the result set.\n"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"count":{"type":"integer","format":"int64","minimum":0,"description":"Total number of resource.\n"},"items":{"type":"array","items":{"type":"object","properties":{"id":{"allOf":[{"type":"string","description":"The unique ID of the resource.\n"}],"description":"The unique ID of billing.\n"},"prefix":{"type":"string","minLength":1,"maxLength":64,"description":"The call prefix of the rating.\n"},"type":{"type":"string","enum":["LOCAL","NATIONAL","INTERNATIONAL","MOBILE"],"default":"LOCAL","description":"The type of the rating:  \nCan be either:  \n- `LOCAL`:  \n- `NATIONAL`:  \n- `INTERNATIONAL`:  \n- `MOBILE`:\n"},"free_seconds":{"type":"integer","format":"int32","minimum":0,"description":"Free seconds of the rating.\n"},"grace_period":{"type":"integer","format":"int32","minimum":0,"description":"Grace period of the rating.\n"},"interval_1":{"type":"integer","format":"int32","minimum":1,"description":"The first interval of the rating.\n"},"interval_n":{"type":"integer","format":"int32","minimum":1,"description":"The subsequent interval of the rating after the first one.\n"},"postcall_surcharge":{"type":"number","format":"double","minimum":0,"description":"Postcall surcharge of the rating. Precision is five digits.\n"},"price_1":{"type":"number","format":"double","minimum":0,"description":"The price of the first interval. Precision is five digits.\n"},"price_n":{"type":"number","format":"double","minimum":0,"description":"The price of the subsequent interval after the first one. Precision is five digits.\n"},"description":{"type":"string","maxLength":1024,"description":"The description text for this rule.\n"}}}}}}}}},"4XX":{"description":"Error"}}}}}}
```

## Create a call rate

> Add a new call rate into system.<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/call_rates":{"post":{"tags":["Billing"],"operationId":"createCallRate","summary":"Create a call rate","description":"Add a new call rate into system.\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"prefix":{"type":"string","minLength":1,"maxLength":64,"description":"The call prefix of the rating.\n"},"type":{"type":"string","enum":["LOCAL","NATIONAL","INTERNATIONAL","MOBILE"],"default":"LOCAL","description":"The type of the rating:  \nCan be either:  \n- `LOCAL`:  \n- `NATIONAL`:  \n- `INTERNATIONAL`:  \n- `MOBILE`:\n"},"free_seconds":{"type":"integer","format":"int32","minimum":0,"description":"Free seconds of the rating.\n"},"grace_period":{"type":"integer","format":"int32","minimum":0,"description":"Grace period of the rating.\n"},"interval_1":{"type":"integer","format":"int32","minimum":1,"description":"The first interval of the rating.\n"},"interval_n":{"type":"integer","format":"int32","minimum":1,"description":"The subsequent interval of the rating after the first one.\n"},"connect_fee":{"type":"number","format":"double","minimum":0,"description":"Connect fee of the rating. Precision is five digits.\n"},"postcall_surcharge":{"type":"number","format":"double","minimum":0,"description":"Postcall surcharge of the rating. Precision is five digits.\n"},"price_1":{"type":"number","format":"double","minimum":0,"description":"The price of the first interval. Precision is five digits.\n"},"price_n":{"type":"number","format":"double","minimum":0,"description":"The price of the subsequent interval after the first one. Precision is five digits.\n"},"description":{"type":"string","maxLength":1024,"description":"The description text for this rule.\n"}},"required":["prefix","type","free_seconds","grace_period","interval_1","interval_n","connect_fee","postcall_surcharge","price_1","price_n"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"allOf":[{"type":"string","description":"The unique ID of the resource.\n"}],"description":"The unique ID of billing.\n"}}}}}},"4XX":{"description":"Error"}}}}}}
```

## Retrieve a call rate

> Retrieve call rate by it's unique ID.<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/call_rates/{id}":{"get":{"tags":["Billing"],"operationId":"getCallRate","summary":"Retrieve a call rate","description":"Retrieve call rate by it's unique ID.\n","parameters":[{"name":"id","in":"path","required":true,"schema":{"allOf":[{"type":"string","description":"The unique ID of the resource.\n"}],"description":"The unique ID of billing.\n"},"description":"The unique ID of the call rate."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"allOf":[{"type":"string","description":"The unique ID of the resource.\n"}],"description":"The unique ID of billing.\n"},"prefix":{"type":"string","minLength":1,"maxLength":64,"description":"The call prefix of the rating.\n"},"type":{"type":"string","enum":["LOCAL","NATIONAL","INTERNATIONAL","MOBILE"],"default":"LOCAL","description":"The type of the rating:  \nCan be either:  \n- `LOCAL`:  \n- `NATIONAL`:  \n- `INTERNATIONAL`:  \n- `MOBILE`:\n"},"free_seconds":{"type":"integer","format":"int32","minimum":0,"description":"Free seconds of the rating.\n"},"grace_period":{"type":"integer","format":"int32","minimum":0,"description":"Grace period of the rating.\n"},"interval_1":{"type":"integer","format":"int32","minimum":1,"description":"The first interval of the rating.\n"},"interval_n":{"type":"integer","format":"int32","minimum":1,"description":"The subsequent interval of the rating after the first one.\n"},"connect_fee":{"type":"number","format":"double","minimum":0,"description":"Connect fee of the rating. Precision is five digits.\n"},"postcall_surcharge":{"type":"number","format":"double","minimum":0,"description":"Postcall surcharge of the rating. Precision is five digits.\n"},"price_1":{"type":"number","format":"double","minimum":0,"description":"The price of the first interval. Precision is five digits.\n"},"price_n":{"type":"number","format":"double","minimum":0,"description":"The price of the subsequent interval after the first one. Precision is five digits.\n"},"description":{"type":"string","maxLength":1024,"description":"The description text for this rule.\n"}}}}}},"4XX":{"description":"Error"}}}}}}
```

## Update a call rate

> Update call rate.<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/call_rates/{id}":{"post":{"tags":["Billing"],"operationId":"updateCallRate","summary":"Update a call rate","description":"Update call rate.\n","parameters":[{"name":"id","in":"path","required":true,"schema":{"allOf":[{"type":"string","description":"The unique ID of the resource.\n"}],"description":"The unique ID of billing.\n"},"description":"The unique ID of the call rate."}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"prefix":{"type":"string","minLength":1,"maxLength":64,"description":"The call prefix of the rating.\n"},"type":{"type":"string","enum":["LOCAL","NATIONAL","INTERNATIONAL","MOBILE"],"default":"LOCAL","description":"The type of the rating:  \nCan be either:  \n- `LOCAL`:  \n- `NATIONAL`:  \n- `INTERNATIONAL`:  \n- `MOBILE`:\n"},"free_seconds":{"type":"integer","format":"int32","minimum":0,"description":"Free seconds of the rating.\n"},"grace_period":{"type":"integer","format":"int32","minimum":0,"description":"Grace period of the rating.\n"},"interval_1":{"type":"integer","format":"int32","minimum":1,"description":"The first interval of the rating.\n"},"interval_n":{"type":"integer","format":"int32","minimum":1,"description":"The subsequent interval of the rating after the first one.\n"},"connect_fee":{"type":"number","format":"double","minimum":0,"description":"Connect fee of the rating. Precision is five digits.\n"},"postcall_surcharge":{"type":"number","format":"double","minimum":0,"description":"Postcall surcharge of the rating. Precision is five digits.\n"},"price_1":{"type":"number","format":"double","minimum":0,"description":"The price of the first interval. Precision is five digits.\n"},"price_n":{"type":"number","format":"double","minimum":0,"description":"The price of the subsequent interval after the first one. Precision is five digits.\n"},"description":{"type":"string","maxLength":1024,"description":"The description text for this rule.\n"}}}}}},"responses":{"200":{"description":"OK"},"4XX":{"description":"Error"}}}}}}
```

## Delete a call rate

> Destroy a call rate.<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/call_rates/{id}/destroy":{"post":{"tags":["Billing"],"operationId":"deleteCallRate","summary":"Delete a call rate","description":"Destroy a call rate.\n","parameters":[{"name":"id","in":"path","required":true,"schema":{"allOf":[{"type":"string","description":"The unique ID of the resource.\n"}],"description":"The unique ID of billing.\n"},"description":"The unique ID of the call rate."}],"responses":{"204":{"description":"No Content"},"4XX":{"description":"Error"}}}}}}
```

## Export call rates

> Export a collection of call rates to file.<br>

```json
{"openapi":"3.1.0","info":{"title":"PortSIP PBX Rest API","version":"22.0"},"tags":[{"name":"Billing","description":"Manage your billing.\n"}],"servers":[{"url":"{protocol}://{hostname}:{port}/api","variables":{"protocol":{"description":"Self-hosted Enterprise Server protocol.","default":"https"},"hostname":{"description":"Self-hosted Enterprise Server hostname.","default":"HOSTNAME"},"port":{"description":"Self-hosted Enterprise Server port.","default":"8887"}}}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}}},"paths":{"/call_rates/export":{"get":{"tags":["Billing"],"operationId":"exportCallRates","summary":"Export call rates","description":"Export a collection of call rates to file.\n","responses":{"200":{"description":"OK","headers":{"Content-Disposition":{"schema":{"type":"string"},"description":"the format is `attachment; filename=\"example\"`"}},"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"4XX":{"description":"Error"}}}}}}
```
