Skip to main content
POST
Create affiliate

πŸ“Œ Endpoint

POST /stores/{storeId}/affiliates Creates a new affiliate in the store. The code (slug) is used to build the promotion link: https://YOUR_DOMAIN.com.br/l/{code}.

πŸ” Authentication

  • Private route.
  • Requires the Authorization header with your API key and an active plan.

🧾 Route parameters


πŸ“€ Body (JSON)


βœ… Request example


πŸ“¦ Success response (201)


⚠️ Possible errors

  • 400 INVALID_DATA β†’ invalid body
  • 400 INVALID_DATA_NAME β†’ name missing or outside 1 to 56 characters
  • 400 INVALID_DATA_EMAIL β†’ email missing, invalid, or longer than 120 characters
  • 400 INVALID_DATA_CODE β†’ code missing, outside 3 to 50 characters, or invalid slug format
  • 400 INVALID_DATA_IMAGE β†’ invalid image (invalid http/https URL or longer than 512 characters)
  • 400 INVALID_DATA_METADATA β†’ invalid metadata (not an object or exceeds 64 keys)
  • 400 INVALID_DATA_RULES β†’ invalid commissionRules (not an array)
  • 400 INVALID_COMMISSION_RULES β†’ empty commissionRules
  • 400 INVALID_COMMISSION_RULE_TYPE β†’ invalid type
  • 400 INVALID_COMMISSION_RULE_POSITION β†’ invalid/duplicated position
  • 400 INVALID_COMMISSION_VALUE β†’ commission outside 1 to 100
  • 400 COMMISSION_RULE_DEFAULT_REQUIRED β†’ exactly one DEFAULT rule is required
  • 400 INVALID_COMMISSION_RULE_TARGET β†’ DEFAULT with targetId, or PRODUCT/CATEGORY/COUPON without targetId
  • 400 RELATION_NOT_FOUND β†’ product/category/coupon targetId does not exist in the store
  • 401 API_KEY_NOT_PROVIDED β†’ Authorization header not provided
  • 401 INVALID_API_KEY β†’ invalid API key
  • 401 UNAUTHENTICATED β†’ unauthenticated user
  • 403 USER_DISABLED β†’ user disabled
  • 403 NO_ACTIVE_SUBSCRIPTION β†’ no active plan
  • 404 STORE_NOT_FOUND β†’ store not found
  • 409 AFFILIATE_ALREADY_EXISTS β†’ code already exists
  • 409 AFFILIATE_EMAIL_ALREADY_EXISTS β†’ email already registered by another affiliate in the store
  • 429 RATE_LIMIT_EXCEEDED β†’ per-minute rate limit exceeded
  • 500 INTERNAL_SERVER_ERROR β†’ internal server error
  • 503 SERVICE_UNAVAILABLE β†’ service unavailable

Authorizations

Authorization
string
header
default:YOUR_API_KEY_HERE
required

Path Parameters

storeId
string
required
Required string length: 1 - 50

Body

application/json

Affiliate details (name, email, code, commissionRules).

name
string
required
Required string length: 1 - 56
email
string<email>
required
Maximum string length: 120
code
string
required
Required string length: 3 - 50
Pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
image
string | null
Maximum string length: 512
metadata
object | null
commissionRules
object[] | null
Minimum array length: 1

Response

Create affiliate.

code
string
required
Example:

"AFFILIATE_CREATED"

affiliate
object
required

Store affiliate (referral code, commission, and stats).