Use a person's own account
Connect a person's own account on a site once, with their phone or email and the code the site sends. Their later bookings there can then sign in as them and pay with the card the account holds.
What it does
The API calls a connected account a session: its routes are under /v3/sessions and its id starts vss_. This page says "connected account".
Ophelia opens the site's sign-in, enters the person's phone or email, and the site sends them a code. You send that code. Ophelia keeps the signed-in account under your end_user id for that site.
site is the host: connecting on opheliapractice.com/shop gives opheliapractice.com.expires_at is when the site's own sign-in runs out, as its sign-in cookie says (the practice site gives 30 days). created_at and connected_at say when it was first connected; on a connected account they are equal. After expires_at, or once the site stops accepting it, the connected account reads failed with reconnect_required.Connect an account
siteurlend_userprofile.phone or profile.email+15551234567) or a 10-digit US number.profile.given_nameThe answer is 201 once the site has answered: here it sent the code. next_action says a code is due and when the chance to send it ends, about 10 minutes later. A connect that ends failed at once is 201 too, with the object and its error_code. Continue, GET and DELETE answer 200.
If the site takes longer to answer, you get 202 with status: "connecting". Read GET /v3/sessions/{session_id} until it changes.
Send the code
Ask the person for the code the site sent them, and send it as code (otp_code also works).
account.name is the name the site greets the person by. A wrong code ends the connect with 200 and status: "failed". It is not asked for again, unlike a code in a booking:
To try again, connect again with POST /v3/sessions and the site sends a new code. A connect sent within 30 seconds of a code answers with the connected account already waiting for that code, so the person is not sent a second one.
Statuses
connectingrequires_actionnext_action.expires_at.activefailederror_code says why.disconnectedList and read
List a person's connected accounts with GET /v3/sessions. Filter with end_user and site. Read one with GET /v3/sessions/{session_id}; it answers the same object as above.
Use it in a booking
On POST /v3/bookings for the same site, send the same end_user with authorize.sign_in: true and authorize.fill_identity: true. Ophelia signs in as the person before it books. To pay with the account's saved card, add authorize.payment: "account_on_file" with a ceiling; the full rules and an example are on Pay.
The answer is the booking (here, succeeded with order PX-509759). The booking keeps the connected account's sign-in up to date. If the site asked to sign in anyway, or answered account_required or password_required, the connected account then reads failed with reconnect_required: connect it again.
commitit places the order or the reservation in the person's own name, on their own card, and v3 cannot undo it.Disconnect
DELETE /v3/sessions/{session_id} deletes the saved sign-in. Do it when the person asks you to forget the account.
What can go wrong
A refused request answers {"error_code", "error"}:
400 end_user_requiredend_user.400 phone_or_email_requiredprofile.phone or profile.email.400 phone_invalid400 no_site, unresolvable_site, private_addresssite.400 code_requiredcode. (A booking's continue with no code answers 400 invalid_input instead.)403 merchant_not_enabled_for_keyallowed_sites). Turn it on for the key in the dashboard, or use a key that has it.404 session_not_found409 not_awaiting_code409 continue_in_flight200 processing.)503 sessions_unavailable503 with Retry-After: 60drive_capacity, no_clean_exit). Wait the seconds given and connect again.A connect that ends failed says why in error_code:
otp_invalidotp_not_sentpassword_requiredaccount_requiredattempt_expirednext_action.expires_at, or the sign-in did not finish. Connect again.reconnect_requirederror_code names the wall. Try later.POST /v3/sessions shares one budget with POST /v3/bookings: 10 every 5 minutes for your organization. The two continue routes share 20. See Rate limits.
In a booking, authorize.sign_in without authorize.fill_identity or end_user is 400, naming the missing field.
Next: Know what an answer means.