# Create commission

POST https://services.leadconnectorhq.com/affiliate-manager/{locationId}/commission

Create a manual commission for a customer.

## Authentication

Send `Authorization: Bearer <token>` using any one of:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `affiliate-manager.write`
- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `affiliate-manager.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location Id |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-04-15"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/affiliate-manager/{locationId}/commission": {
      "post": {
        "summary": "Create commission",
        "operationId": "createCommission",
        "description": "Create a manual commission for a customer.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location Id",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCommissionDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateCommissionResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "affiliate-manager.write"
            ]
          },
          {
            "Location-Access": [
              "affiliate-manager.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "CreateCommissionDto": {
        "type": "object",
        "properties": {
          "affiliateId": {
            "type": "string",
            "description": "Affiliate Id",
            "example": "6385d230f6d19db03eef6fb2"
          },
          "campaignId": {
            "type": "string",
            "description": "Campaign Id",
            "example": "6385d230f6d19db03eef6fb3"
          },
          "customerId": {
            "type": "string",
            "description": "Customer Id",
            "example": "6385d230f6d19db03eef6fb4"
          },
          "amount": {
            "type": "number",
            "description": "Amount. Must not be negative.",
            "example": 100,
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 currency code",
            "example": "USD",
            "enum": [
              "USD",
              "CAD",
              "EUR",
              "AED",
              "AFN",
              "ALL",
              "AMD",
              "ARS",
              "AUD",
              "AZN",
              "BAM",
              "BBD",
              "BDT",
              "BGN",
              "BHD",
              "BIF",
              "BMD",
              "BND",
              "BOB",
              "BRL",
              "BWP",
              "BYR",
              "BZD",
              "CDF",
              "CHF",
              "CLP",
              "CNY",
              "COP",
              "CRC",
              "CVE",
              "CZK",
              "DJF",
              "DKK",
              "DOP",
              "DZD",
              "EEK",
              "EGP",
              "ERN",
              "ETB",
              "GBP",
              "GEL",
              "GHS",
              "GNF",
              "GTQ",
              "HKD",
              "HNL",
              "HRK",
              "HUF",
              "IDR",
              "ILS",
              "INR",
              "IQD",
              "IRR",
              "ISK",
              "JMD",
              "JOD",
              "JPY",
              "KGS",
              "KES",
              "KHR",
              "KMF",
              "KRW",
              "KWD",
              "KZT",
              "LBP",
              "LKR",
              "LTL",
              "LVL",
              "LYD",
              "MAD",
              "MDL",
              "MGA",
              "MKD",
              "MMK",
              "MOP",
              "MUR",
              "MXN",
              "MYR",
              "MZN",
              "NAD",
              "NGN",
              "NIO",
              "NOK",
              "NPR",
              "NZD",
              "OMR",
              "PAB",
              "PEN",
              "PHP",
              "PKR",
              "PLN",
              "PYG",
              "QAR",
              "RON",
              "RSD",
              "RUB",
              "RWF",
              "SAR",
              "SDG",
              "SEK",
              "SGD",
              "SOS",
              "SRD",
              "SYP",
              "THB",
              "TND",
              "TOP",
              "TRY",
              "TTD",
              "TWD",
              "TZS",
              "UAH",
              "UGX",
              "UYU",
              "UZS",
              "VEF",
              "VND",
              "VUV",
              "XAF",
              "XCD",
              "XOF",
              "YER",
              "ZAR",
              "ZMK",
              "CUP",
              "KPW",
              "MRO",
              "ANG",
              "STN",
              "TMT",
              "ZWD",
              "KYD",
              "WST",
              "AWG",
              "AOA",
              "BSD",
              "BYN",
              "FJD",
              "FKP",
              "GIP",
              "GMD",
              "GYD",
              "HTG",
              "LAK",
              "LRD",
              "LSL",
              "MNT",
              "MVR",
              "MWK",
              "PGK",
              "SCR",
              "SHP",
              "SLE",
              "STD",
              "SZL",
              "TJS",
              "XPF",
              "ZMW"
            ]
          },
          "description": {
            "type": "string",
            "description": "Description",
            "example": "Manual commission"
          },
          "eventDate": {
            "format": "date-time",
            "type": "string",
            "description": "Event Date",
            "example": "2023-08-02T00:00:00.000Z"
          },
          "eventId": {
            "type": "string",
            "description": "Event Id",
            "example": "manual-event-123"
          }
        },
        "required": [
          "affiliateId",
          "campaignId",
          "customerId",
          "amount",
          "currency"
        ],
        "title": "CreateCommissionDto"
      },
      "CreateCommissionResponseDto": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Commission id",
            "example": "6385d230f6d19db03eef6fb2"
          },
          "locationId": {
            "type": "string",
            "description": "Location id the commission belongs to",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "campaignId": {
            "type": "string",
            "description": "Campaign id",
            "example": "6385d230f6d19db03eef6fb3"
          },
          "affiliateId": {
            "type": "string",
            "description": "Affiliate id",
            "example": "6385d230f6d19db03eef6fb2"
          },
          "customerId": {
            "type": "string",
            "description": "Customer id",
            "example": "6385d230f6d19db03eef6fb4"
          },
          "transactionId": {
            "type": "string",
            "description": "Transaction id. Generated for manual commissions, which have no upstream transaction",
            "example": "6385d230f6d19db03eef6fb5"
          },
          "payoutId": {
            "type": "string",
            "description": "Payout the commission was added to",
            "example": "6385d230f6d19db03eef6fb6"
          },
          "plan": {
            "type": "string",
            "description": "Product name the commission was earned on",
            "example": "Manual Commission"
          },
          "productId": {
            "type": "string",
            "description": "Product id the commission was earned on. Always \"manual\" for a manually created commission",
            "example": "manual"
          },
          "qty": {
            "type": "number",
            "description": "Quantity",
            "example": 1
          },
          "amount": {
            "type": "number",
            "description": "Base amount the commission was calculated on",
            "example": 100
          },
          "unitDiscount": {
            "type": "number",
            "description": "Unit discount applied before calculating the commission",
            "example": 0
          },
          "commission": {
            "type": "number",
            "description": "Configured commission percentage or flat value",
            "example": 25
          },
          "commissionType": {
            "type": "string",
            "description": "Commission type",
            "example": "percentage"
          },
          "commissionAmount": {
            "type": "number",
            "description": "Calculated commission amount",
            "example": 25
          },
          "currency": {
            "type": "string",
            "description": "Currency",
            "example": "USD"
          },
          "status": {
            "type": "string",
            "description": "Commission Status",
            "example": "approved",
            "enum": [
              "pending",
              "approved",
              "paid",
              "denied"
            ]
          },
          "payoutAt": {
            "type": "string",
            "description": "Month the commission is paid out in",
            "example": "2024-06-01T00:00:00.000Z"
          },
          "dueAt": {
            "type": "string",
            "description": "Due date",
            "example": "2024-06-30T00:00:00.000Z"
          },
          "liveMode": {
            "type": "boolean",
            "description": "Whether the commission is in live mode",
            "example": true
          },
          "isTrial": {
            "type": "boolean",
            "description": "Whether the commission is a trial commission",
            "example": false
          },
          "tier": {
            "type": "string",
            "description": "Commission tier",
            "example": "first",
            "enum": [
              "first",
              "second",
              "third",
              "fourth",
              "fifth",
              "sixth",
              "seventh"
            ]
          },
          "creationSource": {
            "type": "string",
            "description": "How the commission was created",
            "example": "manual",
            "enum": [
              "order",
              "invoice",
              "manual",
              "external-payment",
              "lead-commission",
              "first-promoter"
            ]
          },
          "eventId": {
            "type": "string",
            "description": "Event id supplied on the request",
            "example": "manual-event-123"
          },
          "deleted": {
            "type": "boolean",
            "description": "Whether the commission is deleted",
            "example": false
          },
          "createdBy": {
            "description": "Created by audit metadata",
            "example": {
              "source": "INTEGRATION",
              "channel": "OAUTH",
              "sourceId": "6385d230f6d19db03eef6fb7",
              "sourceName": "Marketplace App"
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "Source of the action",
                    "example": "INTEGRATION"
                  },
                  "channel": {
                    "type": "string",
                    "description": "Channel the action came through",
                    "example": "OAUTH"
                  },
                  "sourceId": {
                    "type": "string",
                    "description": "Source id of the actor",
                    "example": "6385d230f6d19db03eef6fb7"
                  },
                  "sourceName": {
                    "type": "string",
                    "description": "Source name of the actor",
                    "example": "Marketplace App"
                  },
                  "createdAt": {
                    "type": "string",
                    "description": "Timestamp when the action happened",
                    "example": "2024-06-16T00:00:00.000Z"
                  }
                },
                "title": "CommissionAuditResponseDto"
              }
            ]
          },
          "lastUpdatedBy": {
            "description": "Last updated by audit metadata",
            "example": {
              "source": "INTEGRATION",
              "channel": "OAUTH",
              "sourceId": "6385d230f6d19db03eef6fb7",
              "sourceName": "Marketplace App"
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "Source of the action",
                    "example": "INTEGRATION"
                  },
                  "channel": {
                    "type": "string",
                    "description": "Channel the action came through",
                    "example": "OAUTH"
                  },
                  "sourceId": {
                    "type": "string",
                    "description": "Source id of the actor",
                    "example": "6385d230f6d19db03eef6fb7"
                  },
                  "sourceName": {
                    "type": "string",
                    "description": "Source name of the actor",
                    "example": "Marketplace App"
                  },
                  "createdAt": {
                    "type": "string",
                    "description": "Timestamp when the action happened",
                    "example": "2024-06-16T00:00:00.000Z"
                  }
                },
                "title": "CommissionAuditResponseDto"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "description": "Created at timestamp",
            "example": "2024-06-16T00:00:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "description": "Updated at timestamp",
            "example": "2024-06-16T00:00:00.000Z"
          }
        },
        "required": [
          "_id",
          "locationId",
          "campaignId",
          "affiliateId",
          "customerId",
          "transactionId",
          "productId",
          "qty",
          "amount",
          "currency",
          "tier",
          "creationSource",
          "deleted",
          "createdAt",
          "updatedAt"
        ],
        "title": "CreateCommissionResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/commission' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "affiliateId": "6385d230f6d19db03eef6fb2",
  "campaignId": "6385d230f6d19db03eef6fb3",
  "customerId": "6385d230f6d19db03eef6fb4",
  "amount": 100,
  "currency": "USD",
  "description": "Manual commission",
  "eventDate": "2023-08-02T00:00:00.000Z",
  "eventId": "manual-event-123"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "affiliateId": "6385d230f6d19db03eef6fb2",
      "campaignId": "6385d230f6d19db03eef6fb3",
      "customerId": "6385d230f6d19db03eef6fb4",
      "amount": 100,
      "currency": "USD",
      "description": "Manual commission",
      "eventDate": "2023-08-02T00:00:00.000Z",
      "eventId": "manual-event-123"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/affiliate-manager/<locationId>/commission', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/affiliate-manager/{locationId}/commission"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-04-15"
}

payload = {
    "affiliateId": "6385d230f6d19db03eef6fb2",
    "campaignId": "6385d230f6d19db03eef6fb3",
    "customerId": "6385d230f6d19db03eef6fb4",
    "amount": 100,
    "currency": "USD",
    "description": "Manual commission",
    "eventDate": "2023-08-02T00:00:00.000Z",
    "eventId": "manual-event-123"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/commission',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "affiliateId": "6385d230f6d19db03eef6fb2",
  "campaignId": "6385d230f6d19db03eef6fb3",
  "customerId": "6385d230f6d19db03eef6fb4",
  "amount": 100,
  "currency": "USD",
  "description": "Manual commission",
  "eventDate": "2023-08-02T00:00:00.000Z",
  "eventId": "manual-event-123"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/affiliate-manager/<locationId>/commission")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .header("Content-Type", "application/json")
  .body("{\"affiliateId\":\"6385d230f6d19db03eef6fb2\",\"campaignId\":\"6385d230f6d19db03eef6fb3\",\"customerId\":\"6385d230f6d19db03eef6fb4\",\"amount\":100,\"currency\":\"USD\",\"description\":\"Manual commission\",\"eventDate\":\"2023-08-02T00:00:00.000Z\",\"eventId\":\"manual-event-123\"}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/affiliate-manager/<locationId>/commission"
  payload := strings.NewReader(`{
  "affiliateId": "6385d230f6d19db03eef6fb2",
  "campaignId": "6385d230f6d19db03eef6fb3",
  "customerId": "6385d230f6d19db03eef6fb4",
  "amount": 100,
  "currency": "USD",
  "description": "Manual commission",
  "eventDate": "2023-08-02T00:00:00.000Z",
  "eventId": "manual-event-123"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-04-15")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/affiliate-manager/<locationId>/commission")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"
request["Content-Type"] = "application/json"
request.body = '{
  "affiliateId": "6385d230f6d19db03eef6fb2",
  "campaignId": "6385d230f6d19db03eef6fb3",
  "customerId": "6385d230f6d19db03eef6fb4",
  "amount": 100,
  "currency": "USD",
  "description": "Manual commission",
  "eventDate": "2023-08-02T00:00:00.000Z",
  "eventId": "manual-event-123"
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-04-15"
}

$body = '{
  "affiliateId": "6385d230f6d19db03eef6fb2",
  "campaignId": "6385d230f6d19db03eef6fb3",
  "customerId": "6385d230f6d19db03eef6fb4",
  "amount": 100,
  "currency": "USD",
  "description": "Manual commission",
  "eventDate": "2023-08-02T00:00:00.000Z",
  "eventId": "manual-event-123"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/commission' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
