Skip to main content
PUT
Update affiliate

πŸ“Œ Endpoint

PUT /stores/{storeId}/affiliates/{affiliateId} Updates an affiliate’s data (name, email, code, image, status, metadata, and commission rules). All fields are optional β€” only the sent fields are changed.

πŸ” Authentication

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

🧾 Route parameters


πŸ“€ Body (JSON)


βœ… Request example


πŸ“¦ Success response (200)


⚠️ Possible errors

  • 400 INVALID_DATA β†’ invalid body
  • 400 INVALID_DATA_NAME β†’ name outside 1 to 56 characters
  • 400 INVALID_DATA_EMAIL β†’ invalid email or longer than 120 characters
  • 400 INVALID_DATA_IMAGE β†’ invalid image (invalid http/https URL or longer than 512 characters)
  • 400 INVALID_DATA_CODE β†’ code outside 3 to 50 characters or invalid slug format
  • 400 INVALID_DATA_STATUS β†’ invalid status (must be ativo or inativo)
  • 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
  • 404 AFFILIATE_NOT_FOUND β†’ affiliate not found
  • 409 AFFILIATE_ALREADY_EXISTS β†’ code already used by another affiliate
  • 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
affiliateId
string
required
Required string length: 1 - 50

Body

application/json

Affiliate fields to update.

name
string
Required string length: 1 - 56
email
string<email>
Maximum string length: 120
code
string
Required string length: 3 - 50
Pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
image
string | null
Maximum string length: 512
status
enum<string>
Available options:
ativo,
inativo
metadata
object | null
commissionRules
object[]

Response

Update affiliate.

code
string
required
Example:

"AFFILIATE_UPDATED"

affiliate
object
required

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