(account)
Use the Account endpoint to view and manage customer accounts. Perform actions such as creating an account, updating an address, or adding a payment method. This endpoint is for merchants using the Accounts Package. See our related guide on Bolt OAuth.
- get_account - Get Account Details
- create_account - Create Bolt Account
- update_account_profile - Update Profile
- add_address - Add Address
- delete_address - Delete Address
- replace_address - Replace Address
- edit_address - Edit Address
- detect_account - Detect Account
- add_payment_method - Add Payment Method
- delete_payment_method - Delete Payment Method
Fetch a shopper's account details to pre-fill checkout fields. This request must come from your backend for security purposes, as it requires the use of your private key to authenticate. For PCI compliance, only limited information is returned for each credit card available in the shopper’s wallet.
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
res = bolt.account.get_account(security=models.GetAccountSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
))
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
security |
models.GetAccountSecurity | ✔️ | N/A |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Create a Bolt shopping account.
from bolt_api_sdk import Bolt, models
import os
with Bolt(
security=models.Security(
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
),
) as bolt:
res = bolt.account.create_account(create_account_input={
"addresses": [
{
"company": "Bolt",
"country": "United States",
"country_code": "US",
"door_code": "123456",
"email": "alan.watts@example.com",
"first_name": "Alan",
"last_name": "Watts",
"locality": "Brooklyn",
"name": "Alan Watts",
"phone": "+12125550199",
"postal_code": "10044",
"region": "NY",
"region_code": "NY",
"street_address1": "888 main street",
"street_address2": "apt 3021",
"street_address3": "c/o Alicia Watts",
"street_address4": "Bridge Street Apartment Building B",
"metadata": {},
},
],
"payment_methods": [
{
"billing_address": {
"company": "Bolt",
"country": "United States",
"country_code": "US",
"default": True,
"door_code": "123456",
"email": "alan.watts@example.com",
"first_name": "Alan",
"last_name": "Watts",
"locality": "Brooklyn",
"name": "Alan Watts",
"phone": "+12125550199",
"postal_code": "10044",
"region": "NY",
"region_code": "NY",
"street_address1": "888 main street",
"street_address2": "apt 3021",
"street_address3": "c/o Alicia Watts",
"street_address4": "Bridge Street Apartment Building B",
},
"billing_address_id": None,
"bin": "411111",
"expiration": "2025-11",
"last4": "1234",
"metadata": {},
"postal_code": "10044",
"token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0",
"token_type": models.PaymentMethodAccountTokenType.BOLT,
},
],
"profile": {
"email": "alan.watts@example.com",
"first_name": "Alan",
"last_name": "Watts",
"metadata": {},
"phone": "+12125550199",
},
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. |
idempotency_key |
Optional[str] | ➖ | A key created by merchants that ensures POST and PATCH requests are only performed once. Read more about Idempotent Requests here. |
create_account_input |
Optional[models.CreateAccountInput] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Update the identifiers for a shopper's profile (first name or last name).
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
res = bolt.account.update_account_profile(security=models.UpdateAccountProfileSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
), update_profile={
"first_name": "Alan",
"last_name": "Watts",
"metadata": {},
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
security |
models.UpdateAccountProfileSecurity | ✔️ | N/A |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. |
update_profile |
Optional[models.UpdateProfile] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Add an address to a shopper's account address book.
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
res = bolt.account.add_address(security=models.AddAddressSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
), address_account={
"company": "Bolt",
"country": "United States",
"country_code": "US",
"door_code": "123456",
"email": "alan.watts@example.com",
"first_name": "Alan",
"last_name": "Watts",
"locality": "Brooklyn",
"name": "Alan Watts",
"phone": "+12125550199",
"postal_code": "10044",
"region": "NY",
"region_code": "NY",
"street_address1": "888 main street",
"street_address2": "apt 3021",
"street_address3": "c/o Alicia Watts",
"street_address4": "Bridge Street Apartment Building B",
"metadata": {},
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
security |
models.AddAddressSecurity | ✔️ | N/A |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. |
idempotency_key |
Optional[str] | ➖ | A key created by merchants that ensures POST and PATCH requests are only performed once. Read more about Idempotent Requests here. |
address_account |
Optional[models.AddressAccount] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Deletes an existing address in a shopper's address book.
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
bolt.account.delete_address(security=models.DeleteAddressSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
), id="<id>")
# Use the SDK ...| Parameter | Type | Required | Description |
|---|---|---|---|
security |
models.DeleteAddressSecurity | ✔️ | N/A |
id |
str | ✔️ | The ID for an address in the shopper's Address Book. |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Replace an existing address in a shopper's address book. These changes delete the existing address and create a new one.
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
res = bolt.account.replace_address(security=models.ReplaceAddressSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
), id="<id>", country_code="US", email="alan.watts@example.com", first_name="Alan", last_name="Watts", locality="Brooklyn", postal_code="10044", region="NY", street_address1="888 main street", company="Bolt", country="United States", door_code="123456", name="Alan Watts", phone="+12125550199", region_code="NY", street_address2="apt 3021", street_address3="c/o Alicia Watts", street_address4="Bridge Street Apartment Building B", metadata={})
# Handle response
print(res)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
security |
models.ReplaceAddressSecurity | ✔️ | N/A | |
id |
str | ✔️ | The ID for an address in the shopper's Address Book. | |
country_code |
str | ✔️ | The ISO 3166-1 alpha-2 country code associated with this address. | US |
email |
str | ✔️ | An email address. | alan.watts@example.com |
first_name |
str | ✔️ | The given name of the person associated with this address. | Alan |
last_name |
str | ✔️ | The surname of the person associated with this address. | Watts |
locality |
str | ✔️ | The city name details associated with this address. | Brooklyn |
postal_code |
str | ✔️ | The the postal or zip code associated with this address. | 10044 |
region |
str | ✔️ | Not Required for NON US addresses. The region details such as state or province associated with this address. | NY |
street_address1 |
str | ✔️ | The street number and street name of the address. | 888 main street |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. | |
idempotency_key |
Optional[str] | ➖ | A key created by merchants that ensures POST and PATCH requests are only performed once. Read more about Idempotent Requests here. |
|
company |
Optional[str] | ➖ | The company name associated with this address. | Bolt |
country |
Optional[str] | ➖ | The name of the country associated with this address. | United States |
default |
Optional[bool] | ➖ | Set this to true to make this the default shipping address. There can be only one address with default set to true. | |
door_code |
OptionalNullable[str] | ➖ | The building door code or community gate code. | 123456 |
name |
Optional[str] | ➖ | The given and surname of the person associated with this address. | Alan Watts |
phone |
Optional[str] | ➖ | A phone number following E164 standards, in its globalized format, i.e. prepended with a plus sign. | +12125550199 |
region_code |
OptionalNullable[str] | ➖ | The ISO 3166-2 region code associated with this address. - * If specified, value must be valid for the country.- * If null, value is inferred from the region. |
NY |
street_address2 |
Optional[str] | ➖ | Any apartment, floor, or unit details. | apt 3021 |
street_address3 |
OptionalNullable[str] | ➖ | Any additional street address details. | c/o Alicia Watts |
street_address4 |
OptionalNullable[str] | ➖ | Any additional street address details. | Bridge Street Apartment Building B |
metadata |
OptionalNullable[models.ShopperMetadata] | ➖ | A key-value pair object that allows users to store arbitrary information associated with an object. For any individual account object, we allow up to 50 keys. Keys can be up to 40 characters long and values can be up to 500 characters long. Metadata should not contain any sensitive customer information, like PII (Personally Identifiable Information). For more information about metadata, see our documentation. |
{ "customer_id": 234 } |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Edit an existing address in a shopper's address book. This endpoint fully replaces the information for an existing address while retaining the same address ID.
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
res = bolt.account.edit_address(security=models.EditAddressSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
), id="<id>", country_code="US", email="alan.watts@example.com", first_name="Alan", last_name="Watts", locality="Brooklyn", postal_code="10044", region="NY", street_address1="888 main street", company="Bolt", country="United States", door_code="123456", name="Alan Watts", phone="+12125550199", region_code="NY", street_address2="apt 3021", street_address3="c/o Alicia Watts", street_address4="Bridge Street Apartment Building B", metadata={})
# Handle response
print(res)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
security |
models.EditAddressSecurity | ✔️ | N/A | |
id |
str | ✔️ | The ID for an address in the shopper's Address Book. | |
country_code |
str | ✔️ | The ISO 3166-1 alpha-2 country code associated with this address. | US |
email |
str | ✔️ | An email address. | alan.watts@example.com |
first_name |
str | ✔️ | The given name of the person associated with this address. | Alan |
last_name |
str | ✔️ | The surname of the person associated with this address. | Watts |
locality |
str | ✔️ | The city name details associated with this address. | Brooklyn |
postal_code |
str | ✔️ | The the postal or zip code associated with this address. | 10044 |
region |
str | ✔️ | Not Required for NON US addresses. The region details such as state or province associated with this address. | NY |
street_address1 |
str | ✔️ | The street number and street name of the address. | 888 main street |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. | |
company |
Optional[str] | ➖ | The company name associated with this address. | Bolt |
country |
Optional[str] | ➖ | The name of the country associated with this address. | United States |
default |
Optional[bool] | ➖ | Set this to true to make this the default shipping address. There can be only one address with default set to true. | |
door_code |
OptionalNullable[str] | ➖ | The building door code or community gate code. | 123456 |
name |
Optional[str] | ➖ | The given and surname of the person associated with this address. | Alan Watts |
phone |
Optional[str] | ➖ | A phone number following E164 standards, in its globalized format, i.e. prepended with a plus sign. | +12125550199 |
region_code |
OptionalNullable[str] | ➖ | The ISO 3166-2 region code associated with this address. - * If specified, value must be valid for the country.- * If null, value is inferred from the region. |
NY |
street_address2 |
Optional[str] | ➖ | Any apartment, floor, or unit details. | apt 3021 |
street_address3 |
OptionalNullable[str] | ➖ | Any additional street address details. | c/o Alicia Watts |
street_address4 |
OptionalNullable[str] | ➖ | Any additional street address details. | Bridge Street Apartment Building B |
metadata |
OptionalNullable[models.ShopperMetadata] | ➖ | A key-value pair object that allows users to store arbitrary information associated with an object. For any individual account object, we allow up to 50 keys. Keys can be up to 40 characters long and values can be up to 500 characters long. Metadata should not contain any sensitive customer information, like PII (Personally Identifiable Information). For more information about metadata, see our documentation. |
{ "customer_id": 234 } |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Check whether an account exists using one of email, phone, or sha256_email as the unique identifier.
from bolt_api_sdk import Bolt
with Bolt() as bolt:
res = bolt.account.detect_account(x_publishable_key="<value>")
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
x_publishable_key |
str | ✔️ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard. |
email |
Optional[str] | ➖ | The shopper's email address is the primary mechanism for detecting an account. You must provide either a value for this parameter or for sha256_email. |
sha256_email |
Optional[str] | ➖ | The sha256 hash of the shopper's normalized email address can be used to detect an account instead of email. |
phone |
Optional[str] | ➖ | The shopper's phone number. Includes country code (e.g. +1); does not include dashes or spaces. Can be used to detect an account instead of sha256_email or email. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorsBoltAPIResponse | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
Add a payment method to a shopper's Bolt account Wallet. For security purposes, this request must come from your backend because authentication requires the use of your private key.
Note: Before using this API, the credit card details must be tokenized using Bolt's JavaScript library function, which is documented in Install the Bolt Tokenizer.
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
res = bolt.account.add_payment_method(security=models.AddPaymentMethodSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
), request_body={
"billing_address": {
"company": "Bolt",
"country": "United States",
"country_code": "US",
"default": True,
"door_code": "123456",
"email": "alan.watts@example.com",
"first_name": "Alan",
"last_name": "Watts",
"locality": "Brooklyn",
"name": "Alan Watts",
"phone": "+12125550199",
"postal_code": "10044",
"region": "NY",
"region_code": "NY",
"street_address1": "888 main street",
"street_address2": "apt 3021",
"street_address3": "c/o Alicia Watts",
"street_address4": "Bridge Street Apartment Building B",
},
"billing_address_id": None,
"bin": "411111",
"expiration": "2025-11",
"last4": "1234",
"metadata": {},
"postal_code": "10044",
"token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0",
"token_type": models.AddPaymentMethodTokenType.BOLT,
"currency": "USD",
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
security |
models.AddPaymentMethodSecurity | ✔️ | N/A |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. |
idempotency_key |
Optional[str] | ➖ | A key created by merchants that ensures POST and PATCH requests are only performed once. Read more about Idempotent Requests here. |
request_body |
Optional[models.AddPaymentMethodRequestBody] | ➖ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Delete a saved payment method from a shopper's Bolt account Wallet.
from bolt_api_sdk import Bolt, models
import os
with Bolt() as bolt:
bolt.account.delete_payment_method(security=models.DeletePaymentMethodSecurity(
o_auth=os.getenv("BOLT_O_AUTH", ""),
x_api_key=os.getenv("BOLT_X_API_KEY", ""),
), payment_method_id="<id>")
# Use the SDK ...| Parameter | Type | Required | Description |
|---|---|---|---|
security |
models.DeletePaymentMethodSecurity | ✔️ | N/A |
payment_method_id |
str | ✔️ | The ID for a payment method in the shopper's Bolt account Wallet. This ID can be obtained using Get Account Details. |
x_publishable_key |
Optional[str] | ➖ | The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorsBoltAPIResponse | 403, 404 | application/json |
| errors.APIError | 4XX, 5XX | */* |