Skip to contentSkip to navigationSkip to topbar
On this page

Update the Credits for a Subuser



API Overview

api-overview page anchor

For more information about Subusers, visit the longform Subusers documentation. You can also manage Subusers in the SendGrid console(link takes you to an external page).


PUT/v3/subusers/{subuser_name}/credits

Base url: https://api.sendgrid.com (for global users and subusers)

Base url: https://api.eu.sendgrid.com (for EU regional subusers)

This endpoint allows you to update the Credits for a Subuser.


Authentication

authentication page anchor
Property nameTypeRequiredDescription
Authorizationstringrequired
Default: Bearer <<YOUR_API_KEY_HERE>>
Property nameTypeRequiredDescription
subuser_namestringrequired

The username of the Subuser.

Encoding type:application/json
Schema
Property nameTypeRequiredDescriptionChild properties
typeenum<string>required

Type determines how credits are reset for a Subuser. unlimited indicates that there is no limit to the Subuser's credits. recurring indicates that the credits for the Subuser are reset according to the frequency determined by reset_frequency. nonrecurring indicates that there is no recurring schedule to reset credits and resets must be done on an ad hoc basis.

Possible values:
unlimitedrecurringnonrecurring

reset_frequencyenum<string>Optional

The frequency with which a Subuser's credits are reset if type is set to recurring. Do not include reset_frequency if you choose a reset type value of unlimited or nonrecurring.

Possible values:
monthlyweeklydaily

totalintegerOptional

Total number of credits to which the Subuser is to be reset. If type is nonrecurring then the Subuser's credits will be reset to total on a one-time basis. If type is recurring then the Subuser's credits will be reset to total every time a reset is scheduled in accordance with the reset_frequency. Do not include total if you choose a reset type value of unlimited.

Minimum: 1
200400
SchemaExample
Property nameTypeRequiredDescriptionChild properties
typeenum<string>

Type determines how credits are reset for a Subuser. unlimited indicates that there is no limit to the Subuser's credits. recurring indicates that the credits for the Subuser are reset according to the frequency determined by reset_frequency. nonrecurring indicates that there is no recurring schedule to reset credits and resets must be done on an ad hoc basis.

Possible values:
unlimitedrecurringnonrecurring

reset_frequencyenum<string> or null

The frequency with which a Subuser's credits are reset if type is set to recurring, otherwise null.

Possible values:
monthlyweeklydaily

remaininteger or null

Total number of remaining credits. remain is null if the reset type for the Subuser's credits is set to unlimited.

Minimum: 0

totalinteger or null

Total number of allowable credits. total is null if the reset type for the Subuser's credits is set to unlimited or nonrecurring.

Minimum: 0

usedinteger or null

Total number of used credits. used is null if the reset type for the Subuser's credits is set to unlimited or nonrecurring.

Minimum: 0
Update the Credits for a Subuser (recurring)Link to code sample: Update the Credits for a Subuser (recurring)
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const subuser_name = "some_one";
5
const data = {
6
type: "recurring",
7
reset_frequency: "monthly",
8
total: 100,
9
};
10
11
const request = {
12
url: `/v3/subusers/${subuser_name}/credits`,
13
method: "PUT",
14
body: data,
15
};
16
17
client
18
.request(request)
19
.then(([response, body]) => {
20
console.log(response.statusCode);
21
console.log(response.body);
22
})
23
.catch((error) => {
24
console.error(error);
25
});
Update the Credits for a Subuser (non-recurring)Link to code sample: Update the Credits for a Subuser (non-recurring)
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const subuser_name = "some_one";
5
const data = {
6
type: "nonrecurring",
7
total: 100,
8
};
9
10
const request = {
11
url: `/v3/subusers/${subuser_name}/credits`,
12
method: "PUT",
13
body: data,
14
};
15
16
client
17
.request(request)
18
.then(([response, body]) => {
19
console.log(response.statusCode);
20
console.log(response.body);
21
})
22
.catch((error) => {
23
console.error(error);
24
});
Update the Credits for a Subuser (unlimited)Link to code sample: Update the Credits for a Subuser (unlimited)
1
const client = require("@sendgrid/client");
2
client.setApiKey(process.env.SENDGRID_API_KEY);
3
4
const subuser_name = "some_one";
5
const data = {
6
type: "unlimited",
7
};
8
9
const request = {
10
url: `/v3/subusers/${subuser_name}/credits`,
11
method: "PUT",
12
body: data,
13
};
14
15
client
16
.request(request)
17
.then(([response, body]) => {
18
console.log(response.statusCode);
19
console.log(response.body);
20
})
21
.catch((error) => {
22
console.error(error);
23
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.