Harness Platform SDK
A production-grade Python SDK for the Harness platform API. Built with Pydantic v2, httpx, and comprehensive test coverage.
Quick Start
from harness_platform_sdk import HarnessClient
# Create a client
client = HarnessClient(
api_key="your-api-key",
account_id="your-account-id",
default_org="your-org",
default_project="your-project"
)
# Use context manager for automatic cleanup
with client:
# Access resource APIs
orgs = client.organizations.list()
for org in orgs:
print(f"Organization: {org.identifier}")
Installation
pip install harness-platform-sdk
Architecture
Core Modules
-
HarnessClient— Main entry point for all API interactions- HTTP methods with built-in retry (429, 503)
- Scope resolution (account/org/project)
- URL template substitution
- Pagination support (OFFSET and CURSOR styles)
-
HarnessConfig— Configuration management- API key, account ID, base URL
- Timeout, retry settings
- SSL verification control
-
Scope— Request context model- Frozen Pydantic model
- Account ID (required), org/project (optional)
-
Exception Hierarchy
HarnessSdkError— Base exceptionScopeNotSetError— Missing required scope fieldsApiError— Non-2xx responses (with status, body, headers)AuthError— 401/403 responses
-
PaginationStyle— Pagination type enumOFFSET— pageIndex/pageSize paginationCURSOR— nextPageToken pagination
Resource APIs
The SDK includes typed API wrappers for Harness platform resources across multiple domains:
- Next-Gen (Core): Organizations, Projects, Services, Service Overrides, Connectors, Secrets, Infrastructures, Variables, User Groups, Environments V2
- Pipeline: Pipelines (v0), Input Sets (v0), Triggers (v0), Templates (v0)
- Authorization: Roles, Resource Groups, Role Assignments
- Infrastructure as Code: Workspaces, Workspace Approvals, Workspace States, Workspace Variables, Workspace Default Pipelines
- Internal Developer Portal: Entities, Catalog Custom Properties, Scores
Design Principles
- Single Entry Point — All domain APIs are accessed via
HarnessClient - Scope Resolution — Client automatically merges call-time and default scopes
- Type Safety — Full Pydantic v2 models with validation
- Error Handling — Explicit exception types with actionable messages
- Retry Logic — Automatic retry on transient failures with exponential backoff
- No Async — Pure sync using httpx (async support deferred to future version)
Configuration
from harness_platform_sdk import HarnessClient, HarnessConfig
# Option 1: Keyword arguments
client = HarnessClient(
api_key="key",
account_id="acc",
default_org="my-org"
)
# Option 2: Explicit config
config = HarnessConfig(
api_key="key",
account_id="acc",
base_url="https://app.harness.io",
timeout=30.0,
max_retries=3,
retry_status_codes=[429, 503],
retry_enabled=True,
verify_ssl=True
)
client = HarnessClient(config=config)
Error Handling
from harness_platform_sdk import HarnessClient, AuthError, ApiError
client = HarnessClient(api_key="key", account_id="acc")
try:
result = client._get("/some/endpoint")
except AuthError as e:
print(f"Auth failed: {e.status_code}")
# Handle 401/403
except ApiError as e:
print(f"API error: {e.status_code}")
# Handle other non-2xx
finally:
client.close()
Scope Management
from harness_platform_sdk import HarnessClient, Scope
# Set default scope at construction
client = HarnessClient(
api_key="key",
account_id="acc",
default_org="org-1",
default_project="proj-1"
)
# Update default scope
client.set_default_scope(org="org-2", project="proj-2")
# Override scope for a specific call (future: when domain APIs are added)
# resource_manager.get(resource_id, scope=Scope(account_id="acc", org="org-temp"))
Contributing
See CONTRIBUTING.md for development guidelines.
Testing
# Run all tests
mise run tests
# Run with coverage report
mise run tests:cov
# Run specific test file
pytest tests/unit_tests/test_client.py -v
Version
- Current: 1.0.0
- Stability: Production-ready (v1.0.0 release)
License
Business Source License 1.1 (BUSL-1.1) — See License for details.
Metadata
Release files for harness-platform-sdk 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| harness_platform_sdk-1.0.0.tar.gz | 50.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harness_platform_sdk-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 156.1 kB
Release files / harness_platform_sdk-1.0.0.tar.gz
| Download URL | harness_platform_sdk-1.0.0.tar.gz |
|---|---|
| Size | 50.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
466a3a325a8573061f6e877a962d278d450706226dd58a219729223adc4dd9c5
|
|
BLAKE2b-256 checksum How to use checksums |
6c2c2ad8bb6de0fab2950ac4d41fc0d74e1896ab39c63beecced6ef2cbec86bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / harness_platform_sdk-1.0.0-py3-none-any.whl
| Download URL | harness_platform_sdk-1.0.0-py3-none-any.whl |
|---|---|
| Size | 105.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a8948840ca0b71f8b0972d202d1fca8365835b9425792fdef37f881586f339c
|
|
BLAKE2b-256 checksum How to use checksums |
403af451b82113dae28cea8a61124893297d752daa3644548baf5f5c34b3e64c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logSecurity for harness-platform-sdk 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for harness_platform_sdk-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.