WoyraDocs
Get an API key

Take an email plan, or change it

PUT/v1/billing/email_subscription

Billing · Requires an API key

Without a plan, or with one cancelled or past due, the chosen plan is paid for a month from the balance now and that month starts now. A bigger plan than the current one applies at once and charges the difference; a smaller one starts at the next renewal. The same plan again charges nothing, and takes back a cancellation. overage keeps its current value when it is left out.

Body

FieldTypeDescription
up_torequiredintegerThe plan's size
overagebooleanPast the plan's emails

Example

curl -X PUT https://api.woyra.io/v1/billing/email_subscription \
  -H "Authorization: Bearer $WOYRA_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: set-email-subscription-1' \
  -d '{
    "up_to": 1
  }'

Response

200 The plan as it now stands.

FieldTypeDescription
objectrequired"email_subscription"
statusrequiredstringpast_due: the renewal could not be paid. The account sends on the free emails until the balance can pay it, and it renews within the hour of a top-up.
One of active, past_due, cancelled.
planrequiredEmailPlan
currencyrequiredstring
next_planEmailPlanA smaller plan chosen for the next billing month.
overagerequiredboolean
cancel_at_period_endrequiredbooleanCancelled; the plan runs to current_period_end and does not renew.
current_period_startrequiredtimestamp
current_period_endrequiredtimestampWhen the plan renews and its emails reset.
started_atrequiredtimestamp
cancelled_attimestamp

Errors

StatusCodes
400invalid_request, unsupported_version
401authentication_required, invalid_api_key
402insufficient_funds, spend_cap_exceeded, email_limit_reached

Also in Billing