Skip to content

Latest commit

 

History

History
439 lines (304 loc) · 38.5 KB

File metadata and controls

439 lines (304 loc) · 38.5 KB

Billing

Overview

Available Operations

ListPlans

Returns a list of all billing plans for the instance. The plans are returned sorted by creation date, with the newest plans appearing first. This includes both free and paid plans. Pagination is supported.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.ListPlansAsync(
    limit: 20,
    offset: 10
);

// handle response

Parameters

Parameter Type Required Description Example
Paginated bool Whether to paginate the results.
If true, the results will be paginated.
If false, the results will not be paginated.
Limit long Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
20
Offset long Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
10
PayerType PayerType Filter plans by payer type

Response

GetCommercePlanListResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

ListPrices

Returns a list of all prices for the instance. The prices are returned sorted by amount ascending, then by creation date descending. This includes both default and custom prices. Pagination is supported.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.ListPricesAsync(
    limit: 20,
    offset: 10
);

// handle response

Parameters

Parameter Type Required Description Example
Paginated bool Whether to paginate the results.
If true, the results will be paginated.
If false, the results will not be paginated.
Limit long Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
20
Offset long Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
10
PlanId string Filter prices by plan ID

Response

GetBillingPriceListResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

CreatePrice

Creates a custom price for a billing plan. Custom prices allow you to offer different pricing to specific customers while maintaining the same plan structure.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

CreateBillingPriceRequest req = new CreateBillingPriceRequest() {
    PlanId = "<id>",
    Amount = 826545,
};

var res = await sdk.Billing.CreatePriceAsync(req);

// handle response

Parameters

Parameter Type Required Description
request CreateBillingPriceRequest ✔️ The request object to use for the request.

Response

CreateBillingPriceResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

ListSubscriptionItems

Returns a list of all subscription items for the instance. The subscription items are returned sorted by creation date, with the newest appearing first. This includes subscriptions for both users and organizations. Pagination is supported.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;
using Clerk.BackendAPI.Models.Operations;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

GetCommerceSubscriptionItemListRequest req = new GetCommerceSubscriptionItemListRequest() {
    Limit = 20,
    Offset = 10,
};

var res = await sdk.Billing.ListSubscriptionItemsAsync(req);

// handle response

Parameters

Parameter Type Required Description
request GetCommerceSubscriptionItemListRequest ✔️ The request object to use for the request.

Response

GetCommerceSubscriptionItemListResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

CancelSubscriptionItem

Cancel a specific subscription item. The subscription item can be canceled immediately or at the end of the current billing period.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.CancelSubscriptionItemAsync(
    subscriptionItemId: "<id>",
    endNow: false
);

// handle response

Parameters

Parameter Type Required Description
SubscriptionItemId string ✔️ The ID of the subscription item to cancel
EndNow bool Whether to cancel the subscription immediately (true) or at the end of the current billing period (false, default)

Response

CancelCommerceSubscriptionItemResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 403, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

ExtendSubscriptionItemFreeTrial

Extends the free trial period for a specific subscription item to the specified timestamp. The subscription item must be currently in a free trial period, and the plan must support free trials. The timestamp must be in the future and not more than 365 days from the end of the current trial period This operation is idempotent - repeated requests with the same timestamp will not change the trial period.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;
using System;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.ExtendSubscriptionItemFreeTrialAsync(
    subscriptionItemId: "<id>",
    extendFreeTrialRequest: new ExtendFreeTrialRequest() {
        ExtendTo = System.DateTime.Parse("2026-01-08T00:00:00Z"),
    }
);

// handle response

Parameters

Parameter Type Required Description
SubscriptionItemId string ✔️ The ID of the subscription item to extend the free trial for
ExtendFreeTrialRequest ExtendFreeTrialRequest ✔️ Parameters for extending the free trial

Response

ExtendBillingSubscriptionItemFreeTrialResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 403, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

CreatePriceTransition

Creates a price transition for the specified subscription item. This may create an upcoming subscription item or activate immediately depending on plan and payer rules.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.CreatePriceTransitionAsync(
    subscriptionItemId: "<id>",
    priceTransitionRequest: new PriceTransitionRequest() {
        FromPriceId = "<id>",
        ToPriceId = "<id>",
    }
);

// handle response

Parameters

Parameter Type Required Description
SubscriptionItemId string ✔️ The ID of the subscription item to transition
PriceTransitionRequest PriceTransitionRequest ✔️ Parameters for the price transition

Response

CreateBillingPriceTransitionResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 403, 404, 409, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

ListStatements

Returns a list of all billing statements for the instance. The statements are returned sorted by creation date, with the newest statements appearing first. Pagination is supported.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.ListStatementsAsync(
    limit: 20,
    offset: 10
);

// handle response

Parameters

Parameter Type Required Description Example
Paginated bool Whether to paginate the results.
If true, the results will be paginated.
If false, the results will not be paginated.
Limit long Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
20
Offset long Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
10

Response

GetBillingStatementListResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

GetStatement

Retrieves the details of a billing statement.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.GetStatementAsync(statementID: "<id>");

// handle response

Parameters

Parameter Type Required Description
StatementID string ✔️ The ID of the statement to retrieve.

Response

GetBillingStatementResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*

GetStatementPaymentAttempts

Returns a list of all payment attempts for a specific billing statement. The payment attempts are returned sorted by creation date, with the newest payment attempts appearing first. Pagination is supported.

Example Usage

using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

var res = await sdk.Billing.GetStatementPaymentAttemptsAsync(
    statementID: "<id>",
    limit: 20,
    offset: 10
);

// handle response

Parameters

Parameter Type Required Description Example
StatementID string ✔️ The ID of the statement to retrieve payment attempts for.
Paginated bool Whether to paginate the results.
If true, the results will be paginated.
If false, the results will not be paginated.
Limit long Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
20
Offset long Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
10

Response

GetBillingStatementPaymentAttemptsResponse

Errors

Error Type Status Code Content Type
Clerk.BackendAPI.Models.Errors.ClerkErrors 400, 401, 404, 422 application/json
Clerk.BackendAPI.Models.Errors.ClerkErrors 500 application/json
Clerk.BackendAPI.Models.Errors.SDKError 4XX, 5XX */*