Update payment method

PUT /api/payment-method
Sets a new default payment method for the user's Stripe customer.

Request Body

Name Type Description
paymentMethodIdrequired string

Responses

200 Payment method updated
Name Type Description
paymentMethodId string
401 Missing, invalid, or expired authentication token
Name Type Description
errorrequired object
coderequired string Machine-readable error code UNAUTHORIZEDFORBIDDENNOT_FOUNDVALIDATION_FAILEDRATE_LIMITEDSLUG_TAKENSLUG_RESERVEDDOMAIN_IN_USEAPP_LIMIT_REACHEDSUBSCRIPTION_REQUIREDSUBSCRIPTION_EXISTSNO_PAYMENT_METHODNO_ACTIVE_SUBSCRIPTIONNOT_CANCELINGALREADY_CANCELINGSUBSCRIPTION_CANCELINGSAME_PLANCARD_ERRORPAYMENT_ERRORNO_STRIPE_CUSTOMERCERT_CREATION_FAILEDDEPLOY_FAILEDAPI_KEY_LIMIT_REACHEDINVALID_IDEMPOTENCY_KEYIDEMPOTENCY_KEY_REUSEINTERNAL_ERROR
messagerequired string Human-readable error description
docUrl string (uri) Link to relevant API documentation for this error Example: https://orbitkit.io/api/errors/#unauthorized
details object[] Additional validation details (Zod errors)
404 Resource not found
Name Type Description
errorrequired object
coderequired string Machine-readable error code UNAUTHORIZEDFORBIDDENNOT_FOUNDVALIDATION_FAILEDRATE_LIMITEDSLUG_TAKENSLUG_RESERVEDDOMAIN_IN_USEAPP_LIMIT_REACHEDSUBSCRIPTION_REQUIREDSUBSCRIPTION_EXISTSNO_PAYMENT_METHODNO_ACTIVE_SUBSCRIPTIONNOT_CANCELINGALREADY_CANCELINGSUBSCRIPTION_CANCELINGSAME_PLANCARD_ERRORPAYMENT_ERRORNO_STRIPE_CUSTOMERCERT_CREATION_FAILEDDEPLOY_FAILEDAPI_KEY_LIMIT_REACHEDINVALID_IDEMPOTENCY_KEYIDEMPOTENCY_KEY_REUSEINTERNAL_ERROR
messagerequired string Human-readable error description
docUrl string (uri) Link to relevant API documentation for this error Example: https://orbitkit.io/api/errors/#unauthorized
details object[] Additional validation details (Zod errors)
Language
URL
PUT https://api.orbitkit.io/api/payment-method
curl -X PUT "https://api.orbitkit.io/api/payment-method" \
  -H "Authorization: Bearer $ORBITKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"paymentMethodId":"string"}'
const response = await fetch("https://api.orbitkit.io/api/payment-method", {
  method: "PUT",
  headers: {
    "Authorization": "Bearer " + apiKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
      "paymentMethodId": "string"
  }),
});

const data = await response.json();
console.log(data);
var request = URLRequest(url: URL(string: "https://api.orbitkit.io/api/payment-method")!)
request.httpMethod = "PUT"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body: [String: Any] = ["paymentMethodId": "string"]
request.httpBody = try JSONSerialization.data(withJSONObject: body)

let (data, _) = try await URLSession.shared.data(for: request)
let json = try JSONSerialization.jsonObject(with: data)
print(json)
200
{
  "paymentMethodId": "string"
}
401
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or expired token",
    "docUrl": "https://orbitkit.io/api/errors/#unauthorized"
  }
}
404
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Resource not found",
    "docUrl": "https://orbitkit.io/api/errors/#not-found"
  }
}