CreateReportDefinition

Updated at:
Copy as MD

Creates a billing report subscription.

Operation description

When you call this operation, note the following items:

  • You can subscribe to only one type of billing file at a time.

  • Except for monthly billing PDF files, starting from the day after the subscription is created, a billing file that contains all detailed data from the beginning of the current month to the current day is pushed every day. A full billing file for the entire previous billing cycle is pushed before the 4th day of each month.

  • Monthly billing PDF files for the previous month are pushed before the 4th day of each month.

  • Billing files generated on a daily basis may be delayed. Delayed billing files are pushed on the day after they are generated, and may also include billing files that were delayed and generated on the previous day. Pull the full files for the previous month at the beginning of each month.

Note

Apply for permissions by following the instructions in Billing subscription.

  • This subscription and the billing subscription feature in Expenses and Costs are the same feature, and subscriptions are interoperable.

  • When you subscribe to a directory under a bucket, make sure that the directory naming conventions are met:

    • Do not use emojis. Use valid UTF-8 characters.

    • Use forward slashes (/) to separate paths and quickly create subdirectories. Do not start a path with a forward slash (/) or a backslash (), and do not use consecutive forward slashes.

    • Do not use subdirectories named ...

    • Limit the total length to 1 to 254 characters.

  • File names:

    • Example: consumeDetailBillV2 (billing item details)

      • Format of the file name pushed every day: {Account UID}_{Site ID}_{Billing type}_{YYYYMM|YYYYMMDD}. Example: 169**_2688801000001_consumeDetailBillV2_20190312.

      • Format of the complete file name pushed at the beginning of the next month: {Account UID}_{Site ID}_{Billing type}_{YYYYMM|YYYYMM}. Example: 169**_2688801000001_consumeDetailBillV2_201903.

  • Monthly billing PDF files are in the .pdf format, and other files are in the .csv format. When the data volume is large, the system automatically splits an exported bill into multiple files and compresses them into one or more ZIP files. The ZIP file names follow the same format.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

bss:ModifyOssSub

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

ReportSourceType

string

No

The subscription source. Valid values: OSS, MC, and MSC_EMAIL.

OSS

ReportType

string

Yes

The subscription type. Valid values:

  • consumeDetailBillV2: consumption details (supported only by OSS and MC subscriptions).

  • splitDetailBillV2: split details (supported only by OSS and MC subscriptions).

  • costDetailBillV2: cost details (supported only by OSS and MC subscriptions).

  • monthBillOverview: monthly bill summary (supported only by OSS and MSC_EMAIL subscriptions).

  • focus: focus bills (supported only by OSS and MC subscriptions).

consumeDetailBillV2

BeginBillingCycle

string

No

The start billing cycle for data push. After the subscription is created, the system automatically pushes data from the start billing cycle to the current time. This parameter is invalid for monthly billing PDF subscriptions, and historical data is not pushed again. Data within the recent year can be pushed at most.

2025-05

OssBucketOwnerAccountId

integer

No

The UID of the OSS owner that stores the files. Specify this parameter when a BID or reseller subscription needs to push files to the OSS bucket of a RAM user. The RAM user must be a subordinate account of the calling account and must be granted the AliyunConsumeDump2OSSRole permission. Regular users do not need to specify this parameter. The default value is the calling account.

1234567812345678

OssBucketName

string

No

The name of the OSS bucket that stores the files.

sh-bill

OssBucketPath

string

No

The storage path in the OSS bucket.

bill/

McProject

string

No

The name of the MC project.

project

McTableName

string

No

The name of the MC subscription table.

table

Nbid

string

No

The ID of the level-1 site. If this parameter is left empty, the ID of the site to which the current user belongs is used by default.

2684201000001

SplitFileOnUserId

string

No

The email subscription configuration. Specifies whether to split attachments by user ID.

true

NotSendOnNoData

string

No

The email subscription configuration. Specifies whether to skip sending emails when no bills are generated.

true

SendWithAttach

string

No

The email subscription configuration. Specifies whether to include bill attachments in emails.

true

IncludeMembers

string

No

The email subscription configuration. Specifies whether to include enterprise multi-account members in bills.

true

Response elements

Element

Type

Description

Example

object

BeginBillingCycle

string

The start billing cycle for data push. After the subscription is created, the system automatically pushes data from the start billing cycle to the current time. This parameter is invalid for monthly billing PDF subscriptions, and historical data is not pushed again. Data within the recent year can be pushed at most.

2025-05

Metadata

any

The metadata of the response structure.

{}

OssBucketName

string

The name of the OSS bucket that stores the files.

sh-bill

OssBucketOwnerAccountId

integer

The UID of the OSS owner that stores the files. Specify this parameter when a BID or reseller subscription needs to push files to the OSS bucket of a RAM user. The RAM user must be a subordinate account of the calling account and must be granted the AliyunConsumeDump2OSSRole permission. Regular users do not need to specify this parameter. The default value is the calling account.

1234567812345678

OssBucketPath

string

The storage path in the OSS bucket.

bill/

ReportSourceName

string

The name of the subscription source.

OSS

ReportSourceType

string

The subscription source. Valid values: OSS and MC.

OSS

ReportTaskId

integer

The ID of the billing subscription task.

123123

ReportType

string

The subscription type. Valid values:

  • consumeDetailBillV2: consumption details (supported only by OSS and MC subscriptions).

  • splitDetailBillV2: split details (supported only by OSS and MC subscriptions).

  • costDetailBillV2: cost details (supported only by OSS and MC subscriptions).

  • monthBillOverview: monthly bill summary (supported only by OSS and MSC_EMAIL subscriptions).

  • focus: focus bills (supported only by OSS and MC subscriptions).

consumeDetailBillV2

RequestId

string

The ID of the request.

340CAB45-0637-5875-9BE4-EFD5750F6BA5

SubscribeCreateTime

string

The time when the subscription was created. The time is in the YYYY-MM-DD HH:mm:ss format.

2025-05-21 10:36:31

Examples

Success response

JSON format

{
  "BeginBillingCycle": "2025-05",
  "Metadata": "{}",
  "OssBucketName": "sh-bill",
  "OssBucketOwnerAccountId": 1234567812345678,
  "OssBucketPath": "bill/",
  "ReportSourceName": "OSS",
  "ReportSourceType": "OSS",
  "ReportTaskId": 123123,
  "ReportType": "consumeDetailBillV2",
  "RequestId": "340CAB45-0637-5875-9BE4-EFD5750F6BA5",
  "SubscribeCreateTime": "2025-05-21 10:36:31"
}

Error codes

HTTP status code

Error code

Error message

Description

400 TASK_EXIST task has already exist. This table already exists and cannot be resubscribed
400 InvalidBucket The bucket is invalid or the bucket does not belong to you.
400 InvalidHistoricalNbid Historical field does not support subscription bill.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.