Detach a payment method
curl --request DELETE \
--url https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"type": "unprocessable_entity",
"code": "cannot_detach_default_with_subscriptions",
"message": "Cannot delete the default payment method while active subscriptions exist. Please set another payment method as default first.",
"doc_url": "https://docs.altostrat.io/errors/cannot_detach_default_with_subscriptions"
}{
"type": "api_error",
"code": "internal_server_error",
"message": "An internal server error occurred. Please try again later.",
"doc_url": "https://docs.altostrat.io/errors/internal_server_error"
}Payment Methods
Detach a payment method
Detaches a payment method from a billing account. You cannot detach the only payment method on an account, nor can you detach the default payment method if there are active subscriptions.
DELETE
/
workspaces
/
{workspaceId}
/
billing-accounts
/
{billingAccountId}
/
payment-methods
/
{paymentMethodId}
Detach a payment method
curl --request DELETE \
--url https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/payment-methods/{paymentMethodId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"type": "unprocessable_entity",
"code": "cannot_detach_default_with_subscriptions",
"message": "Cannot delete the default payment method while active subscriptions exist. Please set another payment method as default first.",
"doc_url": "https://docs.altostrat.io/errors/cannot_detach_default_with_subscriptions"
}{
"type": "api_error",
"code": "internal_server_error",
"message": "An internal server error occurred. Please try again later.",
"doc_url": "https://docs.altostrat.io/errors/internal_server_error"
}Authorizations
Enter your JWT in the format: Bearer {token}
Path Parameters
The ID of the workspace.
Example:
"ws_a1b2c3d4e5f6g7h8"
The ID of the billing account, which corresponds to a Stripe Customer ID (cus_...).
Example:
"cus_a1b2c3d4e5f6g7h8"
The ID of the Stripe Payment Method (pm_...).
Example:
"pm_a1b2c3d4e5f6g7h8"
Response
The payment method was detached successfully.
Was this page helpful?
⌘I