Skip to content

Upgrade SDK to support Payload API V2#18

Merged
ianhalpern merged 5 commits into
masterfrom
feature/PL-154-api-v2-support
Jan 21, 2026
Merged

Upgrade SDK to support Payload API V2#18
ianhalpern merged 5 commits into
masterfrom
feature/PL-154-api-v2-support

Conversation

@ianhalpern
Copy link
Copy Markdown
Contributor

@ianhalpern ianhalpern commented Dec 9, 2025

Description

This PR adds support for Payload API v2 by implementing version pinning functionality. The SDK now allows users to specify which API version they want to use via the api_version parameter, which is sent as the X-API-Version header on all API requests.

This change enables developers to:

  • Pin their integration to a specific API version for stability
  • Test new API versions before switching their production code
  • Ensure consistent behavior across API updates

Changes include:

  • Added api_version parameter to Session class and global payload module
  • Implemented X-API-Version header in ARMRequest._request() for all HTTP methods
  • Added new API v2 objects
  • Replaced wildcard imports with explicit imports in payload/__init__.py
  • Added __all__ declaration for explicit public API definition
  • Reorganized tests into int/ (integration tests) and unit/ directories
  • Created comprehensive unit tests for api_version header functionality
  • Code formatting improvements for consistency
  • Updated copyright year to 2025

Type of change

  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking change which enhances functionality)

Implementation Details

API Version Support

The api_version parameter can be set in three ways:

  1. Global configuration:
import payload
payload.api_version = 'v2.0'
  1. Session-level configuration:
pl = payload.Session(api_key='key', api_version='v2.0')
  1. Defaults to None: When not set, no version header is sent

@ianhalpern ianhalpern force-pushed the feature/PL-154-api-v2-support branch from 7059b0a to d7eef8e Compare December 9, 2025 15:32
@ianhalpern ianhalpern requested a review from a team December 9, 2025 18:58
Comment thread README.md

```python
import payload as pl
pl.api_key = 'secret_key_3bW9JMZtPVDOfFNzwRdfE'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this isn't a real secret key?

Comment thread README.md
)
```

API v2 introduces new objects including `Profile`, `Intent`, `Entity`, `Transfer`, `ProcessingAgreement`, and more. See the [Payload API Documentation](https://docs.payload.com) for details on API versions.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you wait to merge until the docs are live?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we need to get these out so we can expose the docs.

Comment thread payload/__init__.py
User,
Webhook,
)
from .version import __version__
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you have to adjust all of these imports?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't use * imports which is considered bad practice.

@ianhalpern ianhalpern merged commit 0fd6fb1 into master Jan 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants