2026-02-14 12:59:26 +01:00
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt
> Use this file to discover all available pages before exploring further.
# Order Attribution
2026-02-19 14:31:02 +01:00
> Attribute orders to your builder key for volume credit
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
Order attribution adds builder authentication headers when placing orders through the CLOB, enabling Polymarket to credit trades to your builder account. This allows you to:
2026-02-14 12:59:26 +01:00
* Track volume on the [Builder Leaderboard ](https://builders.polymarket.com/ )
2026-02-19 14:31:02 +01:00
* Earn rewards through the [Builder Program ](/builders/overview )
2026-02-14 12:59:26 +01:00
* Monitor performance via the Data API
** *
## Builder API Credentials
2026-02-19 14:31:02 +01:00
Each builder receives API credentials from their [Builder Profile ](https://polymarket.com/settings?tab=builder ):
2026-02-14 12:59:26 +01:00
| Credential | Description |
| ------------ | ------------------------------------ |
| `key` | Your builder API key identifier |
| `secret` | Secret key for signing requests |
| `passphrase` | Additional authentication passphrase |
<Warning>
2026-02-19 14:31:02 +01:00
Builder API credentials are **not** the same as user API credentials. Builder
credentials are for order attribution only — you still need user credentials
for authentication. Never expose builder credentials in client-side code or
commit them to version control.
2026-02-14 12:59:26 +01:00
</Warning>
** *
2026-03-30 12:53:20 +02:00
## Remote Signing
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
Remote signing keeps your builder credentials secure on a server you control. The user's client sends order details to your server, which adds the builder headers before forwarding to the CLOB.
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
### Server Implementation
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
Your signing server receives request details and returns the authentication headers:
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
<CodeGroup>
```typescript TypeScript theme={null}
import {
buildHmacSignature,
BuilderApiKeyCreds,
} from "@polymarket/builder-signing-sdk";
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
const BUILDER_CREDENTIALS: BuilderApiKeyCreds = {
key: process.env.POLY_BUILDER_API_KEY!,
secret: process.env.POLY_BUILDER_SECRET!,
passphrase: process.env.POLY_BUILDER_PASSPHRASE!,
};
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
// POST /sign - receives { method, path, body } from the client SDK
export async function handleSignRequest(request) {
const { method, path, body } = await request.json();
const timestamp = Date.now().toString();
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
const signature = buildHmacSignature(
BUILDER_CREDENTIALS.secret,
parseInt(timestamp),
method,
path,
body,
);
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
return {
POLY_BUILDER_SIGNATURE: signature,
POLY_BUILDER_TIMESTAMP: timestamp,
POLY_BUILDER_API_KEY: BUILDER_CREDENTIALS.key,
POLY_BUILDER_PASSPHRASE: BUILDER_CREDENTIALS.passphrase,
};
}
` ``
` ``python Python theme={null}
import os
import time
from py_builder_signing_sdk.signing.hmac import build_hmac_signature
from py_builder_signing_sdk import BuilderApiKeyCreds
BUILDER_CREDENTIALS = BuilderApiKeyCreds(
key=os.environ["POLY_BUILDER_API_KEY"],
secret=os.environ["POLY_BUILDER_SECRET"],
passphrase=os.environ["POLY_BUILDER_PASSPHRASE"],
)
# POST /sign - receives { method, path, body } from the client SDK
def handle_sign_request(method: str, path: str, body: str):
timestamp = str(int(time.time()))
signature = build_hmac_signature(
2026-02-14 12:59:26 +01:00
BUILDER_CREDENTIALS.secret,
2026-02-19 14:31:02 +01:00
timestamp,
2026-02-14 12:59:26 +01:00
method,
path,
body
2026-02-19 14:31:02 +01:00
)
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
return {
"POLY_BUILDER_SIGNATURE": signature,
"POLY_BUILDER_TIMESTAMP": timestamp,
"POLY_BUILDER_API_KEY": BUILDER_CREDENTIALS.key,
"POLY_BUILDER_PASSPHRASE": BUILDER_CREDENTIALS.passphrase,
2026-02-14 12:59:26 +01:00
}
2026-02-19 14:31:02 +01:00
` ``
</CodeGroup>
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
### Client Configuration
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
Point the CLOB client to your signing server:
<CodeGroup>
` ``typescript TypeScript theme={null}
import { ClobClient } from "@polymarket/clob-client";
import { BuilderConfig } from "@polymarket/builder-signing-sdk";
const builderConfig = new BuilderConfig({
remoteBuilderConfig: {
url: "https://your-server.com/sign",
token: "optional-auth-token", // optional
},
});
const client = new ClobClient(
"https://clob.polymarket.com",
137,
signer,
apiCreds,
2, // signature type
funderAddress,
undefined,
false,
builderConfig,
);
// Orders automatically include builder headers
const response = await client.createAndPostOrder(/* ... */);
` ``
` ``python Python theme={null}
from py_clob_client.client import ClobClient
from py_builder_signing_sdk import BuilderConfig, RemoteBuilderConfig
builder_config = BuilderConfig(
remote_builder_config=RemoteBuilderConfig(
url="https://your-server.com/sign",
token="optional-auth-token", # optional
2026-02-14 12:59:26 +01:00
)
2026-02-19 14:31:02 +01:00
)
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
client = ClobClient(
host="https://clob.polymarket.com",
chain_id=137,
key=private_key,
creds=api_creds,
signature_type=2,
funder=funder_address,
builder_config=builder_config
)
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
# Orders automatically include builder headers
response = client.create_and_post_order(...)
` ``
2026-03-30 12:53:20 +02:00
` ``rust Rust theme={null}
use polymarket_client_sdk::auth::builder::Config as BuilderConfig;
use polymarket_client_sdk::clob::types::SignatureType;
// First, authenticate as a normal user
let client = Client::new("https://clob.polymarket.com", Config::default())?
.authentication_builder(&signer)
.signature_type(SignatureType::GnosisSafe)
.authenticate()
.await?;
// Then promote to builder with remote signing
let builder_config = BuilderConfig::remote(
"https://your-server.com/sign",
Some("optional-auth-token".to_owned()),
)?;
let client = client.promote_to_builder(builder_config).await?;
// Orders automatically include builder headers
` ``
2026-02-19 14:31:02 +01:00
</CodeGroup>
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
***
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
## Local Signing
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
Sign orders locally when you control the entire order placement flow (e.g., your backend places orders on behalf of users):
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
<CodeGroup>
` ``typescript TypeScript theme={null}
import { ClobClient } from "@polymarket/clob-client";
import {
BuilderConfig,
BuilderApiKeyCreds,
} from "@polymarket/builder-signing-sdk";
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
const builderCreds: BuilderApiKeyCreds = {
key: process.env.POLY_BUILDER_API_KEY!,
secret: process.env.POLY_BUILDER_SECRET!,
passphrase: process.env.POLY_BUILDER_PASSPHRASE!,
};
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
const builderConfig = new BuilderConfig({
localBuilderCreds: builderCreds,
});
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
const client = new ClobClient(
"https://clob.polymarket.com",
137,
signer,
apiCreds,
2,
funderAddress,
undefined,
false,
builderConfig,
);
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
// Orders automatically include builder headers
const response = await client.createAndPostOrder(/* ... */);
` ``
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
` ``python Python theme={null}
import os
from py_clob_client.client import ClobClient
from py_builder_signing_sdk import BuilderConfig, BuilderApiKeyCreds
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
builder_creds = BuilderApiKeyCreds(
key=os.environ["POLY_BUILDER_API_KEY"],
secret=os.environ["POLY_BUILDER_SECRET"],
passphrase=os.environ["POLY_BUILDER_PASSPHRASE"],
)
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
builder_config = BuilderConfig(
local_builder_creds=builder_creds,
)
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
client = ClobClient(
host="https://clob.polymarket.com",
chain_id=137,
key=private_key,
creds=api_creds,
signature_type=2,
funder=funder_address,
builder_config=builder_config
)
2026-02-14 12:59:26 +01:00
2026-02-19 14:31:02 +01:00
# Orders automatically include builder headers
response = client.create_and_post_order(...)
` ``
2026-03-30 12:53:20 +02:00
` ``rust Rust theme={null}
use polymarket_client_sdk::auth::{Credentials, builder::Config as BuilderConfig};
let builder_creds = Credentials::new(
std::env::var("POLY_BUILDER_API_KEY")?.parse()?,
std::env::var("POLY_BUILDER_SECRET")?,
std::env::var("POLY_BUILDER_PASSPHRASE")?,
);
let builder_config = BuilderConfig::local(builder_creds);
let client = client.promote_to_builder(builder_config).await?;
// Orders automatically include builder headers
` ``
2026-02-19 14:31:02 +01:00
</CodeGroup>
2026-02-14 12:59:26 +01:00
***
## Authentication Headers
The SDK automatically generates and attaches these headers to each request:
| Header | Description |
| ------------------------- | ------------------------------------ |
| ` POLY_BUILDER_API_KEY` | Your builder API key |
| ` POLY_BUILDER_TIMESTAMP` | Unix timestamp of signature creation |
| ` POLY_BUILDER_PASSPHRASE` | Your builder passphrase |
| ` POLY_BUILDER_SIGNATURE` | HMAC signature of the request |
<Info>
2026-02-19 14:31:02 +01:00
With **local signing**, the SDK constructs and attaches these headers
automatically. With **remote signing**, your server returns these headers and
the SDK attaches them.
2026-02-14 12:59:26 +01:00
</Info>
***
2026-02-19 14:31:02 +01:00
## Verifying Attribution
### Get Builder Trades
Query trades attributed to your builder account to verify attribution is working:
<CodeGroup>
` ``typescript TypeScript theme={null}
const trades = await client.getBuilderTrades();
// Filtered by market
const marketTrades = await client.getBuilderTrades({
market: "0xbd31dc8a...",
});
` ``
` ``python Python theme={null}
trades = client.get_builder_trades()
market_trades = client.get_builder_trades(
market="0xbd31dc8a..."
)
` ``
2026-03-30 12:53:20 +02:00
` ``rust Rust theme={null}
use polymarket_client_sdk::clob::types::request::TradesRequest;
let trades = client.builder_trades(&TradesRequest::default(), None).await?;
// Filtered by market
let request = TradesRequest::builder()
.market("0xbd31dc8a...".parse()?)
.build();
let market_trades = client.builder_trades(&request, None).await?;
` ``
2026-02-19 14:31:02 +01:00
</CodeGroup>
Each ` BuilderTrade` includes: ` id`, ` market`, ` assetId`, ` side`, ` size`, ` price`, ` status`, ` outcome`, ` owner`, ` maker`, ` transactionHash`, ` matchTime`, ` fee`, and ` feeUsdc`.
### Revoke Builder API Key
If your credentials are compromised, revoke them immediately:
<CodeGroup>
` ``typescript TypeScript theme={null}
await client.revokeBuilderApiKey();
` ``
` ``python Python theme={null}
client.revoke_builder_api_key()
` ``
2026-03-30 12:53:20 +02:00
` ``rust Rust theme={null}
client.revoke_builder_api_key().await?;
` ``
2026-02-19 14:31:02 +01:00
</CodeGroup>
After revoking, generate new credentials from your [Builder Profile](https://polymarket.com/settings?tab=builder).
***
## Troubleshooting
<AccordionGroup>
<Accordion title="Invalid Signature Errors">
* Verify the request body is passed correctly as JSON - Check that ` path`,
` body`, and ` method` match what the client sends - Ensure your server and
client use the same Builder API credentials
</Accordion>
<Accordion title="Missing Credentials">
Ensure your environment variables are set: - ` POLY_BUILDER_API_KEY` -
` POLY_BUILDER_SECRET` - ` POLY_BUILDER_PASSPHRASE`
</Accordion>
<Accordion title="Volume not appearing on leaderboard">
* Confirm your builder credentials are valid and not revoked - Check that
orders are being placed with the builder config attached - Allow up to 24
hours for volume to appear on the leaderboard
</Accordion>
</AccordionGroup>
** *
2026-02-14 12:59:26 +01:00
## Next Steps
<CardGroup cols={2}>
2026-02-19 14:31:02 +01:00
<Card title="Builder Program" icon="hammer" href="/builders/overview">
Learn about the Builder Program tiers and rewards
2026-02-14 12:59:26 +01:00
</Card>
2026-02-19 14:31:02 +01:00
<Card title="Create Orders" icon="plus" href="/trading/orders/create">
Build, sign, and submit orders
2026-02-14 12:59:26 +01:00
</Card>
</CardGroup>
2026-03-30 12:53:20 +02:00
2026-04-07 14:06:13 +02:00
Built with [Mintlify ](https://mintlify.com ).