Skip to content

Commit c8bfa37

Browse files
authored
Billing insights endpoint documentation (#1121)
1 parent 71aa821 commit c8bfa37

File tree

6 files changed

+199
-1
lines changed

6 files changed

+199
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
operationId: billingInsights_list
2+
3+
summary: List Billing Insights
4+
5+
description: >-
6+
7+
This endpoint returns day-over-day changes in billing resource usage based on nightly invoice items, including total amount, region, SKU, and description for a specified date range. It is important to note that the daily resource usage may not reflect month-end billing totals when totaled for a given month as nightly invoice items do not necessarily encompass all invoicing factors for the entire month.
8+
9+
tags:
10+
- Billing
11+
12+
parameters:
13+
- $ref: 'parameters.yml#/account_urn'
14+
- $ref: 'parameters.yml#/start_date'
15+
- $ref: 'parameters.yml#/end_date'
16+
- $ref: '../../shared/parameters.yml#/per_page'
17+
- $ref: '../../shared/parameters.yml#/page'
18+
19+
responses:
20+
'200':
21+
$ref: 'responses/billing_insights.yml'
22+
23+
'401':
24+
$ref: '../../shared/responses/unauthorized.yml'
25+
26+
'403':
27+
$ref: '../../shared/responses/forbidden.yml'
28+
29+
'404':
30+
$ref: '../../shared/responses/not_found.yml'
31+
32+
'429':
33+
$ref: '../../shared/responses/too_many_requests.yml'
34+
35+
'500':
36+
$ref: '../../shared/responses/server_error.yml'
37+
38+
default:
39+
$ref: '../../shared/responses/unexpected_error.yml'
40+
41+
x-codeSamples:
42+
- $ref: 'examples/curl/billingInsights_list.yml'
43+
- $ref: 'examples/python/billingInsights_list.yml'
44+
45+
security:
46+
- bearer_auth:
47+
- 'billing:read'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/billing/do:team:12345678-1234-1234-1234-123456789012/insights/2025-01-01/2025-01-31?per_page=20&page=1"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
lang: Python
2+
source: |-
3+
import os
4+
from pydo import Client
5+
6+
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
7+
8+
insights = client.billing.list_insights(
9+
account_urn="do:team:12345678-1234-1234-1234-123456789012",
10+
start_date="2025-01-01",
11+
end_date="2025-01-31",
12+
page_size=100,
13+
page_number=1
14+
)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
type: object
2+
3+
properties:
4+
usage_team_urn:
5+
type: string
6+
description: URN of the team that incurred the usage
7+
example: 'do:team:12345678-1234-1234-1234-123456789012'
8+
9+
start_date:
10+
type: string
11+
format: date
12+
description: Start date of the billing data point in YYYY-MM-DD format
13+
example: '2025-01-15'
14+
15+
total_amount:
16+
type: string
17+
description: Total amount for this data point in USD
18+
example: '12.45'
19+
20+
region:
21+
type: string
22+
description: Region where the usage occurred
23+
example: 'nyc3'
24+
25+
sku:
26+
type: string
27+
description: Unique SKU identifier for the billed resource
28+
example: '1-DO-DROP-0109'
29+
30+
description:
31+
type: string
32+
description: Description of the billed resource or service as shown on an invoice item
33+
example: 'droplet name (c-2-4GiB)'
34+
35+
group_description:
36+
type: string
37+
description: Optional invoice item group name of the billed resource or service, blank when not part an invoice item group
38+
example: 'kubernetes cluster name'

specification/resources/billing/parameters.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,33 @@ invoice_uuid:
55
schema:
66
type: string
77
example: 22737513-0ea7-4206-8ceb-98a575af7681
8-
required: true
8+
required: true
9+
10+
account_urn:
11+
name: account_urn
12+
description: URN of the customer account, can be a team (do:team:uuid) or an organization (do:teamgroup:uuid)
13+
in: path
14+
schema:
15+
type: string
16+
example: do:team:12345678-1234-1234-1234-123456789012
17+
required: true
18+
19+
start_date:
20+
name: start_date
21+
description: Start date for billing insights in YYYY-MM-DD format
22+
in: query
23+
schema:
24+
type: string
25+
format: date
26+
example: '2025-01-01'
27+
required: true
28+
29+
end_date:
30+
name: end_date
31+
description: End date for billing insights in YYYY-MM-DD format. Must be within 31 days of start_date
32+
in: query
33+
schema:
34+
type: string
35+
format: date
36+
example: '2025-01-31'
37+
required: true
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
description: >-
2+
The response will be a JSON object that contains a list of billing data points
3+
under the `data_points` key, along with pagination metadata including
4+
`total_items`, `total_pages`, and `current_page`.
5+
6+
headers:
7+
ratelimit-limit:
8+
$ref: '../../../shared/headers.yml#/ratelimit-limit'
9+
ratelimit-remaining:
10+
$ref: '../../../shared/headers.yml#/ratelimit-remaining'
11+
ratelimit-reset:
12+
$ref: '../../../shared/headers.yml#/ratelimit-reset'
13+
14+
content:
15+
application/json:
16+
schema:
17+
type: object
18+
properties:
19+
data_points:
20+
type: array
21+
description: Array of billing data points, which are day-over-day changes in billing resource usage based on nightly invoice item estimates, for the requested period
22+
items:
23+
$ref: '../models/billing_data_point.yml'
24+
25+
total_items:
26+
type: integer
27+
description: Total number of items available across all pages
28+
example: 250
29+
30+
total_pages:
31+
type: integer
32+
description: Total number of pages available
33+
example: 3
34+
35+
current_page:
36+
type: integer
37+
description: Current page number
38+
example: 1
39+
40+
required:
41+
- data_points
42+
- total_items
43+
- total_pages
44+
- current_page
45+
46+
example:
47+
data_points:
48+
- usage_team_urn: 'do:team:12345678-1234-1234-1234-123456789012'
49+
start_date: '2025-01-01'
50+
total_amount: '0.86'
51+
region: 'nyc3'
52+
sku: '1-DO-DROP-0109'
53+
description: 'droplet name (c-2-4GiB)'
54+
group_description: ''
55+
- usage_team_urn: 'do:team:12345678-1234-1234-1234-123456789012'
56+
start_date: '2025-01-01'
57+
total_amount: '2.57'
58+
region: 'nyc3'
59+
sku: '1-KS-K8SWN-00109'
60+
description: '3 nodes - 4 GB / 2 vCPU / 80 GB SSD'
61+
group_description: 'kubernetes cluster name'
62+
total_items: 2
63+
total_pages: 1
64+
current_page: 1

0 commit comments

Comments
 (0)