# Mark Payout Method As Primary

PATCH https://services.leadconnectorhq.com/affiliate-manager/{locationId}/affiliate/{affiliateId}/payout-method/{payoutMethodId}/primary

Make this payout method the one payouts default to. Any other method stops being primary.

## 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 |
| `affiliateId` | string | Yes | Affiliate Id |
| `payoutMethodId` | string | Yes | Payout Method 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}/affiliate/{affiliateId}/payout-method/{payoutMethodId}/primary": {
      "patch": {
        "summary": "Mark Payout Method As Primary",
        "operationId": "markPayoutMethodAsPrimary",
        "description": "Make this payout method the one payouts default to. Any other method stops being primary.",
        "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"
            }
          },
          {
            "name": "affiliateId",
            "required": true,
            "in": "path",
            "description": "Affiliate Id",
            "schema": {
              "example": "63e35ac8b4dac93dfc2757c7",
              "type": "string"
            }
          },
          {
            "name": "payoutMethodId",
            "required": true,
            "in": "path",
            "description": "Payout Method Id",
            "schema": {
              "example": "63e35ac8b4dac93dfc2757c7",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoutMethodResponseDto"
                }
              }
            }
          },
          "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"
          },
          "404": {
            "description": "Not Found"
          },
          "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": {
      "PayoutMethodResponseDto": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Payout method id",
            "example": "63e35ac8b4dac93dfc2757c7"
          },
          "locationId": {
            "type": "string",
            "description": "Location the payout method belongs to",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "affiliateId": {
            "type": "string",
            "description": "Affiliate the payout method belongs to",
            "example": "6385d230f6d19db03eef6fb2"
          },
          "method": {
            "type": "string",
            "description": "Payout method type",
            "example": "PAYPAL",
            "enum": [
              "PAYPAL",
              "BANK"
            ]
          },
          "paypalEmail": {
            "type": "string",
            "description": "PayPal email, when the method is PAYPAL",
            "example": "john@doe.com"
          },
          "bankDetails": {
            "description": "Bank details, when the method is BANK",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "bankCountry": {
                    "type": "string",
                    "description": "Country the account is held in",
                    "example": "United States"
                  },
                  "accountHolderName": {
                    "type": "string",
                    "description": "Name on the account",
                    "example": "John Doe"
                  },
                  "recipientAddress": {
                    "description": "Address of the account holder",
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "country": {
                            "type": "string",
                            "description": "Country of the account holder",
                            "example": "United States"
                          },
                          "state": {
                            "type": "string",
                            "description": "State or province",
                            "example": "California"
                          },
                          "city": {
                            "type": "string",
                            "description": "City",
                            "example": "San Francisco"
                          },
                          "postalCode": {
                            "type": "string",
                            "description": "Postal code",
                            "example": "94105"
                          }
                        },
                        "required": [
                          "country",
                          "city",
                          "postalCode"
                        ],
                        "title": "PayoutMethodRecipientAddressResponseDto"
                      }
                    ]
                  },
                  "fields": {
                    "description": "Bank fields required by the account country, with values reduced to their last four characters",
                    "example": [
                      {
                        "key": "accountNumber",
                        "value": "********5678"
                      },
                      {
                        "key": "bankName",
                        "value": "Bank of America"
                      }
                    ],
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "string",
                          "description": "Field key, as declared by the country bank mapping",
                          "example": "accountNumber"
                        },
                        "value": {
                          "type": "string",
                          "description": "Account-identifying values are masked to their last four characters, with the rest replaced by asterisks so the length is preserved. Descriptive fields such as the bank and branch name are returned in full.",
                          "example": "********5678"
                        }
                      },
                      "required": [
                        "key",
                        "value"
                      ],
                      "title": "PayoutMethodBankFieldResponseDto"
                    }
                  }
                },
                "required": [
                  "bankCountry",
                  "accountHolderName",
                  "recipientAddress",
                  "fields"
                ],
                "title": "PayoutMethodBankDetailsResponseDto"
              }
            ]
          },
          "isPrimary": {
            "type": "boolean",
            "description": "Whether payouts default to this method",
            "example": true
          },
          "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",
          "affiliateId",
          "method",
          "isPrimary",
          "createdAt",
          "updatedAt"
        ],
        "title": "PayoutMethodResponseDto"
      },
      "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 PATCH 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliate/<affiliateId>/payout-method/<payoutMethodId>/primary' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15'
```

**Node.js**

```javascript
const options = {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliate/<affiliateId>/payout-method/<payoutMethodId>/primary', 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}/affiliate/{affiliateId}/payout-method/{payoutMethodId}/primary"

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

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

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliate/<affiliateId>/payout-method/<payoutMethodId>/primary',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PATCH',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
  ],
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .patch("https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliate/<affiliateId>/payout-method/<payoutMethodId>/primary")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliate/<affiliateId>/payout-method/<payoutMethodId>/primary"
  req, _ := http.NewRequest("PATCH", url, nil)
  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>/affiliate/<affiliateId>/payout-method/<payoutMethodId>/primary")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"

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

**PowerShell**

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

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliate/<affiliateId>/payout-method/<payoutMethodId>/primary' -Method 'PATCH' -Headers $headers
$response | ConvertTo-Json
```
