
Creating the payloads
Generate opportunity metadata and the encoded campaign payload ready to be signed
Once you've assembled a configuration (see Understanding campaign configs), the Merkl API turns it into the two payloads you actually use:
- A minimal opportunity payload to preview the metadata Merkl will display for the opportunity.
- A full campaign payload: the encoded
createCampaigncall you broadcast onchain.
1. Opportunity metadata payload
You don't need a full configuration to preview an opportunity, because a minimal subset of fields is enough (the example below is for an ERC20 campaign type; other types expect different fields). The metadata is what Merkl shows for the opportunity (title, target asset, APR, etc.) before the campaign is even live.
{
"campaignType": 60,
"targetToken": "0xBdb9300b7CDE636d9cD4AFF00f6F009fFBBc8EE6",
"computeChainId": 8453,
"distributionChainId": 8453,
"distributionMethodParameters": {
"distributionMethod": "MAX_APR",
"distributionSettings": {
"apr": "0.08",
"rewardTokenPricing": true,
"targetTokenPricing": true
}
}
}
Submit it to:
POST https://api.merkl.xyz/v4/config/opportunity
The response contains the opportunity metadata Merkl will compute for this configuration. Use this endpoint to preview the opportunity, surface its details in your own UI, or validate the inputs before encoding the campaign. Full reference: POST /v4/config/opportunity.
2. Full campaign payload
The body of this endpoint is simply your complete configuration, the one assembled in Understanding campaign configs, wrapped in an array, so you can encode several campaigns in a single batch:
[
{ /* a complete campaign configuration */ },
{ /* …another configuration to batch (optional) */ }
]
Submit it to:
POST https://api.merkl.xyz/v4/config/encode/batch
The response contains the encoded calldata you can hand to a wallet for signing. Full reference: POST /v4/config/encode/batch.
Once you have the encoded payload, head over to Transactions to sign to learn what to broadcast onchain.
Other config endpoints
The config tag of the API reference has the variants you may need:
| Need | Endpoint |
|---|---|
| Encode one campaign | POST /v4/config/encode |
| Safe payload, one or many campaigns | POST /v4/config/encode/safe, POST /v4/config/encode/batch/safe |
| Configuration of an existing campaign | GET /v4/config/decode/onchain/{distributionChainId}/{campaignId}, GET /v4/config/{id} |
| Decode a payload before signing | See Verifying payloads |
| Estimate TVL | POST /v4/config/tvl |