Events
Black records an event for each change in an environment. Each event has a type that names what happened, in the form resource.action.
Find an event type
The table lists every event type. A type's description says what the change was and what data.object holds.
- About. What the event belongs to: the environment as a whole, one customer, or one subscription.
- Facts. The extra values the event carries beside the object, such as the reason a webhook endpoint was switched off. A type with no facts carries none.
| Type | Summary | Description | About | Facts |
|---|---|---|---|---|
api_client.revoked | API client revoked | An API client was revoked for good: neither its secret nor a previous one obtains an access token any more, and every token issued to it is refused from the next request. data.object is the API client as it is now, with revoked true; no part of a secret is ever in it. | environment | None |
api_client.secret_rolled | API client secret rolled | An API client's secret was replaced with a new one, shown only in the answer to the roll; the old secret still obtains access tokens for the period the roll set, up to 7 days, or stopped at once. data.object is the API client as it is now; no part of either secret is ever in it. | environment | None |
app.archived | App archived | An app was archived for good, and data.object is the app with archived_at set. | environment | None |
app.created | App registered | A website or mobile app was registered in the environment, and data.object is the new app. | environment | None |
app.updated | App changed | An app's name or allowed origins were changed, and data.object is the app as it is now, with the fields that changed and their earlier values in data.previous_attributes. | environment | None |
checkout.session.completed | Checkout session paid | A checkout session was paid by Black's own record of the payment, never by the page's word, and its subscription is active; data.object is the checkout session with status complete, its customer and its subscription, and data.previous_attributes.status the status it had. Give access on this event or on a read of the session, never on a visit to the success address alone. | subscription | None |
checkout.session.expired | Checkout session expired | A checkout session expired 24 hours after it was created, unpaid, open or with its last payment declined, and its page no longer takes a payment; data.object is the checkout session with status expired, and data.previous_attributes.status the status it had. | environment | None |
customer.blocked | Customer blocked | A customer was blocked, with the reason in data.reason; each subscription still running ends at once with the reason blocked, and the customer cannot subscribe or pay until unblocked. data.object is the customer as it is now. | customer | reason |
customer.created | Customer created | A customer was created, and data.object is the new customer. | customer | None |
customer.deleted | Customer deleted | A customer was deleted for good, and data.object is the customer as it was just before. | customer | None |
customer.flagged | Customer flagged for review | A customer was flagged for review, with the reason in data.reason; data.object is the customer as it is now, with its flag. | customer | reason |
customer.subscription.created | Subscription created | A subscription was created, and data.object is the new subscription with its items and its latest invoice. | subscription | None |
customer.subscription.deleted | Subscription ended | A subscription ended, for example at the end of its grace period with its renewal invoice still unpaid, and data.object is the subscription after the change, with when and why it ended in canceled_at and cancellation_reason, and the fields that changed and their earlier values in data.previous_attributes. | subscription | None |
customer.subscription.granted | Subscription granted free for one term | A subscription was granted for free for one term of its plan by the account's vendor, the actor of the event; it is active at once with no invoice, never renews, and ends at the end of the term, in data.ends_at, with the reason grant_ended. data.object is the subscription as it is now, and customer.subscription.created was recorded just before. | subscription | ends_at |
customer.subscription.renewal_upcoming | Subscription renewal coming up | A subscription will renew, at the lead time the account set before its renewal, and data.renewal says when, for which period, for how much and at which price for each item, the new price where a change takes effect then, and for a member paying in another currency what the renewal will bill in it, at which exchange rate, set, source and time, and where Black charges the card it will be charged to, with its brand and last 4; data.object is the subscription as it is now. | subscription | renewal |
customer.subscription.updated | Subscription changed | A subscription was changed, by the billing engine (for example renewed or expired), by the account's own request (its metadata), or by the account's renewals being stopped or started again (whether it renews), and data.object is the subscription as it is now, with the fields that changed and their earlier values in data.previous_attributes; when a payment or a renewal made the change, data.invoice gives that invoice's ID, billing reason, currency, subtotal, total, period and, when it is taxed, its tax and its total excluding tax; for an invoice in the member's currency, also its presentment as the invoice shows it and its lines, each with its amount, rate and set in that currency. | subscription | invoice |
customer.unblocked | Customer's block removed | A customer's block was removed, with the reason in data.reason; the customer may subscribe again as new. data.previous_attributes.block is the block it had. | customer | reason |
customer.unflagged | Customer's flag removed | A customer's flag was removed, with the reason in data.reason; data.object is the customer as it is now, and data.previous_attributes.flag the flag it had. | customer | reason |
customer.updated | Customer changed | A customer was changed, and data.object is the customer as it is now, with the fields that changed and their earlier values in data.previous_attributes. | customer | None |
customer_identity.ambiguous | Sign-in email held by several customers | A sign-in arrived with a proved email that several customers of the environment each hold proved, so it was linked to none of them: a new customer was made for it, and data.ambiguity.customers lists the customers who hold the email. data.object is the new identity. | customer | ambiguity |
customer_identity.linked | Way of signing in linked to a customer | A way of signing in with Black's own sign-in was linked to a customer: an email the customer signed up with, or a sign-in matched to them. data.object is the identity: its customer, its provider, its subject, its email and whether that email is proved. It never holds a password, a hash or a token. | customer | None |
customer_identity.removed | Way of signing in removed from a customer | The account removed one of a customer's identities, so that way of signing in no longer signs the customer in; sessions it made live on. data.object is the identity as it was just before. | customer | None |
customer_identity.verified | Sign-in email proved by its customer | A customer proved the email of one of their identities for the first time, by the link Black emailed them at sign-up or by completing a reset of their password. It is told once for an identity, and not again when the email is proved again. data.object is the identity after, with email_verified true and verified_at set. It never holds a password, a hash or a token. | customer | None |
customer_session.created | Customer signed in | A customer signed in to one of the environment's apps and a session began, and data.object is the new session: its customer, its app, how the customer signed in and when it ends. It never holds a token. | customer | None |
customer_session.ended | Customer's session ended early | A customer's session ended before its time, and data.reason says why: the customer signed out everywhere, the account ended the customer's sessions, a refresh token was used a second time, the customer was blocked or deleted, the password was reset or changed, or the account was secured because the owner of its email signed in by a way that proves it while the password was not proved theirs. data.object is the session as it is now, with ended_at set; every token of it is refused from then on. | customer | reason |
customer_session.reused_refresh_token | Refresh token used again, so the session ended | A refresh token of a customer's session was used again after its first use had been answered, outside the few seconds in which a repeat is answered the same pair, so the whole session ends at once and customer_session.ended follows with the reason refresh_token_reused. data.object is the session as it was just before; it never holds a token. | customer | None |
customer_session.token_created | Sign-in token made for a customer | The account's server made a sign-in token for a customer, which a page exchanges once for the customer's session; the event's actor is the caller that made it, and data.object is the customer. It never holds the token. | customer | None |
declines.threshold_reached | Many card payments and saves declined in a short time | Payments on the environment's hosted checkout pages and cards its customers saved in its apps were declined data.threshold times within data.within_seconds seconds, which can mean someone is trying stolen cards; it is sent once each time the count is reached, data.checkout_payments and data.card_saves say how many of those declines were of each kind, and data.object is the environment's settings as they are now. | environment | threshold, within_seconds, checkout_payments, card_saves |
dispute.created | Payment disputed by the customer | A customer disputed a payment of an invoice with their bank, told by the gateway where Black charged the invoice or reported by the account where it collected the money itself, and data.object is the dispute. The membership the invoice belongs to ends at once with the reason chargeback, and the customer is flagged with the reason chargeback, unless already flagged; a payment reported later does not bring the membership back. | subscription | None |
dispute.updated | A dispute's status or details changed | A dispute's status or details changed: it moved to a later state, won, lost, canceled, expired, resolved or accepted, or the gateway gave its category, its reason code or the date its evidence is due. data.object is the dispute as it is now, with the fields that changed and their earlier values in data.previous_attributes. Nothing else changes: a membership the dispute ended stays ended, and the customer's flag stays. | subscription | None |
entitlements.active_entitlement_summary.updated | Customer's entitlements changed | The features a customer is entitled to changed, for example when a subscription became active, renewed with a feature attached or detached, entered or ended its grace, or the customer was deleted, and data.object is the customer's active entitlements after the change, the first 10 with has_more and the url where all are read, with the list before the change in data.previous_attributes.entitlements. | customer | None |
feature.created | Feature created | A feature was created, and data.object is the new feature. | environment | None |
feature.updated | Feature changed | A feature was changed, for example its metadata or whether it is active, and data.object is the feature as it is now, with the fields that changed and their earlier values in data.previous_attributes; data.affected_customers is how many customers of the environment, not deleted, holding a live subscription (incomplete, active or past_due) with an item on a price of a product the feature is attached to. | environment | affected_customers |
gateway_connection.created | Payment gateway connected | A payment gateway was connected to the environment with the account's own credentials, which the gateway accepted, and data.object is the new connection, with the address Black registered for the gateway's notifications; no part of a secret is ever in it. | environment | None |
gateway_connection.disconnected | Payment gateway disconnected | A gateway connection was disconnected: its credentials and signing key were deleted, and the environment's payment mode went back to the account collecting the money itself. data.object is the connection as it is now, with status disconnected. | environment | None |
gateway_connection.updated | Gateway connection changed | A gateway connection changed: its credentials were replaced with new ones the gateway accepted, or the gateway refused the stored ones, so its status is failing, or a call succeeded again, so its status is active. data.object is the connection as it is now, with the fields that changed and their earlier values in data.previous_attributes; no part of a secret is ever in it. | environment | None |
invoice.created | Invoice created | An invoice was created for a subscription, and data.object is the new invoice with its lines. | subscription | None |
invoice.finalized | Invoice finalised and ready to collect | An invoice was finalized and can now be collected, and data.object is the invoice with its amounts and due date. | subscription | None |
invoice.overdue | Invoice overdue | An invoice reached its due date without being paid, and data.object is the invoice as it is now. | subscription | None |
invoice.paid | Invoice paid | An invoice was paid, collected by Black through the account's gateway or reported by the account, which collected the money itself, and data.object is the invoice as it is now, with when it was paid, its payment reference (the gateway's payment where Black collected it) and the account's note. | subscription | None |
invoice.payment_action_required | Invoice payment needs the customer | A payment Black took for an invoice needs the customer: the card asked them to authenticate, and the subscription's next_action gives the address to send them to, or the card cannot be charged while they are away, and they pay the invoice again themselves. data.object is the invoice as it is now. | subscription | None |
invoice.payment_failed | Invoice payment failed | A payment Black took for an invoice failed, and data.object is the invoice as it is now, with the attempts made, the retries left, when the next is due, the reason the last one failed and the card it was charged to. | subscription | None |
invoice.payment_information_requested | Card holder's bank asked about an invoice payment | The card holder's bank asked, through the gateway, for information about a payment Black took for an invoice, before or instead of disputing it; no money is taken, no dispute is opened, the membership does not change and the customer is not flagged. data.object is the invoice as it is now, data.gateway_payment names the payment and data.gateway_request the gateway's ID of the request, and, where the gateway names them, data.category and data.reason_code say why the bank asks and data.respond_by, in Unix seconds, when it is to be answered by. Answer it at the gateway; a request left unanswered may become a dispute. | subscription | gateway_payment, gateway_request, category, reason_code, respond_by |
invoice.payment_outcome_unknown | Invoice payment held, its outcome unknown | A payment Black sent for an invoice may have been taken, but Black cannot learn its outcome: the gateway account it went through is no longer the one the gateway connection reaches, because the connection's credentials were replaced under another client or the gateway was connected anew. Black neither sends it again nor reads it through the new account, and does not fail it; it is held, the invoice stays as it is, and no retry is made while it is held. data.object is the invoice as it is now, data.attempt names the attempt, which is the reference of its payment at the gateway, data.amount and data.currency say what it was for, and data.connection names the connection it went through. Look the payment up by data.attempt in that gateway account, then report what it shows with POST /v1/invoices/{invoice}/payment-outcome: taken, with its payment ID, pays the invoice, and not taken fails the attempt so the invoice can be paid or retried. | subscription | attempt, amount, currency, connection |
invoice.payment_unapplied | Payment taken that could not be applied to the invoice | Black took a payment through the gateway that it could not apply to the invoice, because the invoice or the customer changed while the money was being taken, or the payment's reference is already on another invoice (data.reason payment_reference_in_use), or the payment is set aside for our team (data.reason command_set_aside), or because the gateway took a second payment for the same attempt (data.reason paid_twice), or a checkout's payment came after its subscription had ended, so the checkout was not completed (data.reason subscription_ended), or Black kept trying to process the gateway's notice of the payment for about eight hours and gave up (data.reason unprocessed: the payment will not be applied to the invoice, so refund it); data.object is the invoice, data.reason says why, data.gateway_payment names the payment and, for the first invoice of a subscription a checkout session made, data.checkout_session names that session, so the account can refund it. Black refunds nothing by itself. | subscription | reason, gateway_payment, checkout_session |
invoice.refund_outcome_unknown | Invoice refund held, its outcome unknown | A refund Black asked the gateway for may have been given back, but Black cannot learn its outcome, and it stays pending, held, never failed on a guess. data.reason says why: connection_changed when the invoice's payment went through another gateway connection or Checkout.com client than the one now active, so Black asks the new one nothing, or key_window_passed when the gateway did not answer clearly within the 48 hours it keeps the refund's key, so Black asks it nothing again. data.object is the invoice as it is now, data.refund names the refund, which is the reference of the refund at the gateway, and data.amount and data.currency say what it was for. Look the refund up by data.refund in the gateway account that took the payment. It is sent once for each refund. | subscription | refund, amount, currency, reason |
invoice.voided | Invoice voided | An invoice was voided and is no longer owed, and data.object is the invoice with the time it was voided. | subscription | None |
payment_method.attached | Card saved for a customer | A card was saved for a customer from the single-use token the gateway's own fields made, and data.object is the new payment method, active, with its brand, last 4 digits and expiry; it holds no card number or security code. | customer | None |
payment_method.detached | Customer's card removed | A customer's card was removed at the gateway and can no longer be charged, and data.object is the payment method with status detached; a customer whose default it was has no default until a card is saved or chosen. | customer | None |
payment_method.updated | Customer's default card changed | A customer's default card changed, to a newly saved card or to another of their cards, and every later charge uses it; data.object is the payment method that is now the default. | customer | None |
price.created | Price created | A price was created on a product, and data.object is the new price. | environment | None |
price.updated | Price changed | A price was changed, for example archived or its lookup key moved to another price, and data.object is the price as it is now, with the fields that changed and their earlier values in data.previous_attributes; data.affected_customers is how many customers of the environment, not deleted, holding a live subscription (incomplete, active or past_due) with an item on the price. | environment | affected_customers |
price_move.created | Price move of subscriptions started | The account asked to move the subscriptions on one price to another; data.object holds both prices, the notice period, and how many subscriptions it reaches. Each subscription then records customer.subscription.updated when its move is set. | environment | None |
product.created | Product created | A product was created, and data.object is the new product. | environment | None |
product.deleted | Product deleted | A product was deleted for good, and data.object is the product as it was just before. | environment | None |
product.updated | Product changed | A product was changed, and data.object is the product as it is now, with the fields that changed and their earlier values in data.previous_attributes; data.affected_customers is how many customers of the environment, not deleted, holding a live subscription (incomplete, active or past_due) with an item on a price of the product. | environment | affected_customers |
product_feature.attached | Feature attached to a product | A feature was attached to a product, and data.object is the attachment, with the feature as it is now; data.affected_customers is how many customers of the environment, not deleted, holding a live subscription (incomplete, active or past_due) with an item on a price of the product. | environment | affected_customers |
product_feature.detached | Feature detached from a product | A feature was detached from a product, and data.object is the attachment as it was just before; data.affected_customers is how many customers of the environment, not deleted, holding a live subscription (incomplete, active or past_due) with an item on a price of the product. | environment | affected_customers |
refund.created | Refund asked for or recorded | A refund of an invoice's payment was asked for, and data.object is the refund: where Black charged the invoice, Black asked the gateway to give the money back to the card, and the refund is pending until the gateway answers for good, or failed when the gateway refused it at once, with the reason in failure_reason; where the account collected the money itself, or refunded it at the former gateway client the payment went through, the refund it made is recorded, succeeded at once, with that client's action in gateway_action for the latter. The membership, its status and its benefits do not change. | subscription | None |
refund.updated | Refund succeeded or failed | A refund the gateway was asked for reached its final word, from the gateway or, for a refund held across a change of client, as the account reported it from the former client, made by the actor who reported it; data.object is the refund as it is now: succeeded, the money given back, so the invoice's amount_refunded rose, or failed, with the gateway's reason in failure_reason; data.previous_attributes.status is the status it had. | subscription | None |
settings.updated | Account settings changed | An account's settings were changed, and data.object is the settings as they are now, with the fields that changed and their earlier values in data.previous_attributes; data.affected_customers is how many customers of the environment, not deleted, holding a live subscription (incomplete, active or past_due) the change reaches, which is every one of them. | environment | affected_customers |
test_clock.advancing | Test clock started advancing | A test clock started to advance by request, and data.object is the test clock with status advancing, its frozen_time still the time it had and advancing_to the time it moves to. | environment | None |
test_clock.created | Test clock created | A test clock was created in a test environment, and data.object is the new test clock. | environment | None |
test_clock.deleted | Test clock deleted | A test clock was deleted for good with its customers and their subscriptions, by request or 30 days after its creation, and data.object is the test clock as it was just before. | environment | None |
test_clock.internal_failure | Test clock stopped advancing on a failure | A test clock stopped advancing because work that fell due for one of its customers could not be run, and data.object is the test clock with status internal_failure, its frozen_time the time it had before; it can still be read, renamed and deleted. | environment | None |
test_clock.ready | Test clock finished advancing | A test clock finished advancing: everything that fell due for its customers up to advancing_to has run, and data.object is the test clock with status ready and frozen_time the new time. | environment | None |
test_clock.updated | Test clock renamed | A test clock was renamed, and data.object is the test clock as it is now, with its earlier name in data.previous_attributes. | environment | None |
webhook_endpoint.disabled | Webhook endpoint switched off after failed deliveries | A webhook endpoint was switched off because every delivery to it kept failing, as data.reason says, and it receives no events until it is enabled again. | environment | reason |
Branch on type in your own code, and ignore a type you do not handle. To receive events at an address of yours, see Webhooks.
Read the fields every event carries
An event is one JSON object. Its fields come in this order, and each is present in every event, with the value null where it does not apply.
| Field | Holds |
|---|---|
object | event. |
id | The ID of the event, which starts with evt_. |
type | The event type, in the form resource.action. |
api_version | The API version your account is pinned to. |
livemode | true in a live environment and false in a test environment. |
created | When Black recorded the event, in Unix seconds. |
actor | Who made the change. See below. |
customer | The ID of the customer the event is about. |
customer_sequence | The number of the event among that customer's events. See Put a customer's events in order. |
subscription | The ID of the subscription, for an event about a subscription or one of its invoices. |
subscription_status | The status of that subscription as the change left it, such as active or past_due. |
subscription_status_label | The label of that subscription as the change left it, such as grace_period or pending_cancel. |
prices | The IDs of the prices of the subscription's items, in the order of the items, each price once. |
data | The change itself. See below. |
An event about the environment as a whole, such as a product, a price or the settings, has null in customer, customer_sequence, subscription, subscription_status, subscription_status_label and prices. An event about a customer, such as customer.flagged, has the customer and its number and null in the four fields of a subscription. An event about a subscription or one of its invoices has all six. Every event of one change carries the same subscription_status, so the invoice events of a payment and the subscription update that follows them agree.
actor is an object with a type and an id. These are the types, and what each id is:
| Type | Who | The id |
|---|---|---|
api_client | A client of your account made the change. | The ID of the client. |
app | An app of your environment made the change, for what an account's own sign-in does through it before the customer exists. | The ID of the app. |
checkout_session | The hosted checkout page of a checkout session made the change, for what a customer does on it. | The ID of the checkout session. |
customer | A customer made the change for themselves, through their own session. | The ID of the customer. |
operator | A person at Black made the change. | Always null. |
system | Black's own scheduled work made the change, such as a renewal or the end of grace. | Always null. |
team_member | A person on your account's team made the change. | The ID of the person, which starts with usr_. |
vendor_client | A client of your vendor made the change, acting for your account. | The ID of the client. |
vendor_team_member | A person on your vendor's team made the change, acting in your account. | The ID of the person, which starts with usr_. |
team_memberis a person on your account's team, andidis the person's ID, never a name or an email.vendor_team_memberis a person on your vendor's team, acting in your account, andidis the person's ID.checkout_sessionis a customer paying on a checkout page, andidis the checkout session's ID.customeris a customer acting for themselves, such as signing in, andidis the customer's ID.appis one of your apps, acting before the customer exists, such as when an identity token makes the customer, andidis the app's ID.
data holds three things. data.object is the object the event is about, as it is after the change. data.previous_attributes holds the old value of each field that the change altered, and is null for an event that creates or records something rather than updates it. The facts of the type sit beside them in data, such as data.reason of customer.flagged or data.affected_customers of price.updated. The Facts column of the table names them.
Put a customer's events in order
customer_sequence counts one customer's events from 1, in the order Black recorded them. A number is never skipped and never used twice. An event about the environment as a whole carries no number.
Black does not deliver events in order, so order a customer's events by customer_sequence, not by the order they arrive in.
A gap in the numbers that your endpoint receives has one of two causes. The missing event is of a type that your endpoint does not receive, or it is not delivered yet. To fill the gap, list the customer's events with GET /v1/events?customer={id}. The list shows an event for 30 days after it was created, newest first.
The sample creates a customer, a subscription and the report of its payment, and then lists the customer's events. The oldest event, customer.created, carries customer_sequence 1, and each later event carries the next number. It writes PLACEHOLDER_ACCESS_TOKEN where your access token goes, reads each ID from the response before it, and needs sed. A test environment takes five writes a second, so the sample waits a second between its writes.
TOKEN=PLACEHOLDER_ACCESS_TOKEN
CUSTOMER=$(curl --silent --request POST https://api.black.example/v1/customers \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data '{"name":"Noor","email":"noor@example.com","external_reference":"events-order-guest-7731"}' \
| sed -n 's/.*"id":"\(cus_[0-9a-z]*\)".*/\1/p')
PRODUCT=$(curl --silent --request POST https://api.black.example/v1/products \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data '{"name":"Events Monthly"}' \
| sed -n 's/.*"id":"\(prod_[0-9a-z]*\)".*/\1/p')
PRICE=$(curl --silent --request POST https://api.black.example/v1/prices \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data "{\"product\":\"$PRODUCT\",\"currency\":\"SAR\",\"unit_amount\":6000,\"recurring\":{\"interval\":\"month\",\"interval_count\":1}}" \
| sed -n 's/.*"id":"\(price_[0-9a-z]*\)".*/\1/p')
INVOICE=$(curl --silent --request POST https://api.black.example/v1/subscriptions \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--header "Idempotency-Key: events-order-subscription-7731" \
--data "{\"customer\":\"$CUSTOMER\",\"items\":[{\"price\":\"$PRICE\"}]}" \
| sed -n 's/.*"latest_invoice":"\(in_[0-9a-z]*\)".*/\1/p')
curl --silent --request POST https://api.black.example/v1/invoices/$INVOICE/mark-paid \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data '{"amount":6000,"currency":"SAR","payment_reference":"events-order-payment-7731"}'
curl --silent "https://api.black.example/v1/events?customer=$CUSTOMER" \
--header "Authorization: Bearer $TOKEN"
The subscription request answers 201, and the report and the list answer 200. The list holds customer.created, customer.subscription.created, the events of the first invoice and customer.subscription.updated, with customer_sequence running from 1 to the last event. To run the sample again in the same environment, change the external_reference, the Idempotency-Key and the payment_reference.
Know how many customers a change reaches
A change to the catalogue or to the settings can reach many customers. price.updated, product.updated, feature.updated, product_feature.attached, product_feature.detached and settings.updated carry the fact data.affected_customers, a whole number. It counts the customers that are not deleted and that hold a live subscription the change reaches. A subscription is live when its status is incomplete, active or past_due.
price.updatedcounts the customers with an item on that price.product.updated,product_feature.attachedandproduct_feature.detachedcount the customers with an item on a price of that product.feature.updatedcounts the customers with an item on a price of a product that the feature is attached to now.settings.updatedcounts every customer that holds a live subscription. When the change turnsrenewals_stoppedoff, it counts also the customers whose subscription comes back.
The *.created events and product.deleted carry no count: nothing holds a new object, and a product with prices cannot be deleted.
Find the event for a business moment
Black names an event by what changed, and a business names a moment by what happened. The table maps each business name that Black sends an event for to that event, and says what to read in it. Every event it names is in the table of types above.
| Business name | Event of Black | What to read in it | Page |
|---|---|---|---|
| Subscribed | customer.subscription.updated | data.previous_attributes.status is incomplete and data.object.status is active: the first invoice was reported paid. data.object.metadata holds the booking reference you gave when you created the subscription. The invoice data is in data.invoice: total is the gross, and under tax rules tax and total_excluding_tax are the tax and the net. For a customer with a currency of their own, data.invoice.presentment holds the amounts in that currency with the rate, its set and its time. The invoice.paid just before it holds the same in data.object. | Create a subscription and report its payments, Show and charge in your customer's currency |
| Renewed, when the period rolls | customer.subscription.updated | actor.type is system. data.object.current_period_end is the end of the new period, and data.previous_attributes holds current_period_start, current_period_end and latest_invoice as they were. The renewal's invoice.created and invoice.finalized come just before it. The invoice data is in data.invoice: total is the gross, and under tax rules tax and total_excluding_tax are the tax and the net. For a customer with a currency of their own, data.invoice.presentment holds the amounts in that currency with the rate, its set and its time. The renewal's invoice.created and invoice.finalized hold the same in data.object. | Create a subscription and report its payments, Show and charge in your customer's currency |
| Renewed, when its payment is reported | invoice.paid | data.object.billing_reason is subscription_cycle for the invoice of a renewal, and subscription_create for the first invoice. When the invoice is paid before it is due, the subscription stays active and Black records no subscription update. With days_until_due at its default of 1, a renewal paid within the day records only this event; when it is unpaid at its due date, the renewal goes to Payment Failed, and its payment is Payment Recovered. When days_until_due is 0, the renewal invoice is overdue at once, so the renewal goes straight to Payment Failed. The invoice data is in data.object: total is the gross, and under tax rules tax and total_excluding_tax are the tax and the net. For a customer with a currency of their own, data.object.presentment holds the amounts in that currency with the rate, its set and its time. | Create a subscription and report its payments |
| Payment Failed | invoice.overdue, then customer.subscription.updated | subscription_status of the invoice event is past_due: an invoice that is overdue while the subscription is incomplete is the first invoice, not a failed renewal. In the update, data.object.status is past_due, data.object.status_label is grace_period, and data.object.grace_period_end says when grace ends. data.previous_attributes holds status, status_label, grace_period_end and grace_keeps_entitlements as they were. actor.type is system. | Create a subscription and report its payments |
| Payment Recovered | invoice.paid, then customer.subscription.updated | data.previous_attributes.status is past_due and data.object.status is active. data.previous_attributes also holds the grace fields as they were. The invoice data is in data.invoice of the update and in data.object of the invoice.paid before it: total is the gross, under tax rules tax and total_excluding_tax are the tax and the net, and presentment holds the amounts in the customer's own currency with the rate, its set and its time. | Create a subscription and report its payments, Show and charge in your customer's currency |
| Expired, after grace, a cancel now, the end of a period set to cancel, a customer deleted or blocked, or stopped renewals | customer.subscription.deleted | data.object.end_reason says how it ended: payment_failed, canceled_now, period_end, customer_deleted, customer_blocked or renewals_stopped. actor.type is api_client or vendor_client for a cancel now and system for the others. | Cancel a subscription |
| Expired, an unpaid new subscription | invoice.voided, then customer.subscription.updated | This is an update, not a deletion. data.object.status is incomplete_expired, data.object.end_reason is first_invoice_unpaid, and data.previous_attributes.status is incomplete. actor.type is system. | Create a subscription and report its payments |
| Cancel Scheduled | customer.subscription.updated | data.object.cancel_at_period_end is true and data.object.status_label is pending_cancel. data.object.cancellation_reason holds the reason given, or not_given. | Cancel a subscription |
| Resumed | customer.subscription.updated | The undo of a pending cancel: data.object.cancel_at_period_end is false and data.previous_attributes.cancel_at_period_end is true. | Cancel a subscription |
| Upgraded | invoice.paid, then customer.subscription.updated | The report of an upgrade's offer. data.object.billing_reason of the invoice is subscription_update, and in the update data.previous_attributes.items holds the items as they were. The invoice data is in data.invoice of the update and in data.object of the invoice.paid before it: total is the gross, under tax rules tax and total_excluding_tax are the tax and the net, and presentment holds the amounts in the customer's own currency, each line with the rate of its own set. | Change a customer's plan, Show and charge in your customer's currency |
| Renewal Upcoming | customer.subscription.renewal_upcoming | data.renewal holds renews_at, period_end, amount, currency and items, each with its item, price, quantity, amount and price_changes. actor.type is system. For a customer with a currency of their own, data.renewal.presentment holds the amount and currency that the renewal charges, with the rate and its set, and each item its presentment_amount. Black records it the number of days before the renewal that the setting reminder_lead_days holds. | Change account settings |
| Flagged | customer.flagged | data.reason holds the reason, and data.previous_attributes.flag is null. | Flag a customer and read the activity log |
| Unflagged | customer.unflagged | data.reason holds the reason, and data.previous_attributes.flag holds the flag that was removed. | Flag a customer and read the activity log |
| Blocked | customer.blocked | data.reason holds the reason, and data.previous_attributes.block is null. Each live subscription of the customer then ends with a customer.subscription.deleted whose end_reason is customer_blocked. | None |
| Unblocked | customer.unblocked | data.reason holds the reason, and data.previous_attributes.block holds the block that was lifted. | None |
| Price Changed | price.updated | data.previous_attributes holds the old value of each field that changed, data.affected_customers says how many customers it reaches, and actor says who changed it. | None |
| Discount Changed | feature.updated | data.previous_attributes.metadata holds the old metadata of the feature, data.object.metadata the new one, and data.affected_customers how many customers it reaches. | Check what a customer holds |
| Settings Changed | settings.updated | data.previous_attributes holds the old value of each setting that changed, data.affected_customers says how many customers hold a live subscription, and actor says who changed it. | Change account settings |
A business name that is not in the table is not an event that Black sends.
What a customer holds has its own event, entitlements.active_entitlement_summary.updated. It is not a business name: Black records it when the features a customer holds change, such as after a payment, an end or a block. Read what the customer holds with the lookup in Check what a customer holds.