Repository navigation
Migration guide for v23
This version of the SDK uses API version 2026-10-28.endive. If the format of this API version looks new to you, see our new API release process.
This affects integrations that persist SDK resources or collections in PHP sessions, caches, or queued jobs and rely on their API keys being restored by unserialize().
Native serialize() now replaces the API key in Stripe\Util\RequestOptions with a placeholder, including options attached to resources, nested objects, and collections. Deserialization also discards API keys embedded by earlier SDK versions. You can still read restored data, but you must reattach an API key before making requests through a restored resource:
// Before
$customer = unserialize($trustedStoredCustomer);
$customer->refresh();
// After
$customer = unserialize($trustedStoredCustomer);
$customer->reattachApiKey($apiKeyFromSecureConfiguration);
$customer->refresh();Reattach the API key the same way on restored collections and events before making requests through them:
$customers = unserialize($trustedStoredCustomerList);
$customers->reattachApiKey($apiKeyFromSecureConfiguration);
foreach ($customers->autoPagingIterator() as $customer) {
// ...
}
$event = unserialize($trustedStoredEvent);
$event->reattachApiKey($apiKeyFromSecureConfiguration);
$relatedObject = $event->fetchRelatedObject();reattachApiKey() also attaches API keys to nested restored objects. Each retains its other saved request options, including connected-account and context settings, API version, API base, and retries. Nested objects that already have an API key keep it. Reattachment does not change the global API key, and serializing the object again omits the reattached key.
Requests before reattachment raise Stripe\Exception\AuthenticationException with instructions to call reattachApiKey(), even if you set a global or per-call API key. Calling reattachApiKey() more than once, or on an object whose API key wasn't replaced with the serialization placeholder, raises Stripe\Exception\InvalidArgumentException. Passing an empty key or the serialization placeholder also raises Stripe\Exception\InvalidArgumentException.
Serialized payloads written by earlier SDK versions can still contain API keys. Deserialization discards those keys, but they remain in storage until you remove or replace the payloads. Remove or replace those stored payloads according to your application's storage policy.