# Update Note Relations

PUT https://services.leadconnectorhq.com/notes/{id}/relations

Update Note Relations

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | Yes | Note Id |

### Query 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": {
    "/notes/{id}/relations": {
      "put": {
        "summary": "Update Note Relations",
        "operationId": "updateNoteRelations",
        "description": "Update Note Relations",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Note Id",
            "schema": {
              "example": "ocQHyuzHvysMo5N5VsXc",
              "type": "string"
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location Id",
            "schema": {
              "example": "ocQHyuzHvysMo5N5VsXc",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateNoteRelationsDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetCreateUpdateNoteSuccessfulResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "notes.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": {
      "UpdateNoteRelationsDTO": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "The type of relation update operation",
            "example": "add"
          },
          "relations": {
            "type": "array",
            "description": "List of relations to add or remove",
            "example": [
              {
                "objectKey": "contact",
                "recordId": "sx6wyHhbFdRXh302LLNR"
              }
            ],
            "items": {
              "type": "object",
              "properties": {
                "objectKey": {
                  "type": "string",
                  "description": "The object type for the relation",
                  "example": "contact"
                },
                "recordId": {
                  "type": "string",
                  "description": "The record ID for the relation",
                  "example": "sx6wyHhbFdRXh302LLNR"
                }
              },
              "title": "NotesRelationSchema"
            }
          }
        },
        "required": [
          "type",
          "relations"
        ],
        "title": "UpdateNoteRelationsDTO"
      },
      "GetCreateUpdateNoteSuccessfulResponseDto": {
        "type": "object",
        "properties": {
          "note": {
            "description": "The note object",
            "example": {
              "id": "HGPcayliwcdoUFzvbTok",
              "body": "lorem ipsum",
              "userId": "TUcmRxWrjqzJS8EjkxNK",
              "dateAdded": "2021-07-08T12:02:11.285Z",
              "contactId": "TUcmRxWrjqzJS8EjkxNK"
            },
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Unique identifier for the note",
                "example": "HGPcayliwcdoUFzvbTok"
              },
              "body": {
                "type": "string",
                "description": "The body content of the note",
                "example": "lorem ipsum"
              },
              "userId": {
                "type": "string",
                "description": "The ID of the user who created the note",
                "example": "TUcmRxWrjqzJS8EjkxNK"
              },
              "dateAdded": {
                "type": "string",
                "description": "The date and time when the note was created",
                "example": "2021-07-08T12:02:11.285Z"
              },
              "contactId": {
                "type": "string",
                "description": "The ID of the contact associated with the note",
                "example": "TUcmRxWrjqzJS8EjkxNK"
              },
              "businessId": {
                "type": "string",
                "description": "The ID of the business associated with the note",
                "example": "TUcmRxWrjqzJS8EjkxNK"
              },
              "title": {
                "type": "string",
                "description": "The title of the note",
                "example": "Follow-up summary"
              },
              "color": {
                "type": "string",
                "description": "The color code of the note",
                "example": "#FFAA00"
              },
              "pinned": {
                "type": "boolean",
                "description": "Whether the note is pinned",
                "example": false
              },
              "attachments": {
                "description": "List of attachments associated with the note",
                "example": [
                  {
                    "id": "att_1",
                    "objectKey": "contact",
                    "recordId": "sx6wyHhbFdRXh302LLNR"
                  }
                ],
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Unique identifier for the attachment",
                      "example": "att_1"
                    },
                    "objectKey": {
                      "type": "string",
                      "description": "The object type the attachment is associated with",
                      "example": "contact"
                    },
                    "recordId": {
                      "type": "string",
                      "description": "The record ID the attachment is linked to",
                      "example": "sx6wyHhbFdRXh302LLNR"
                    }
                  },
                  "title": "AttachmentSchema"
                }
              }
            },
            "title": "GetNoteSchema"
          }
        },
        "title": "GetCreateUpdateNoteSuccessfulResponseDto"
      },
      "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 PUT 'https://services.leadconnectorhq.com/notes/<id>/relations?locationId=<LOCATIONID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "type": "add",
  "relations": [
    {
      "objectKey": "contact",
      "recordId": "sx6wyHhbFdRXh302LLNR"
    }
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "type": "add",
      "relations": [
        {
          "objectKey": "contact",
          "recordId": "sx6wyHhbFdRXh302LLNR"
        }
      ]
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/notes/<id>/relations?locationId=<LOCATIONID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/notes/{id}/relations"

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

params = {
    "locationId": "<LOCATIONID>"
}

payload = {
    "type": "add",
    "relations": [
        {
            "objectKey": "contact",
            "recordId": "sx6wyHhbFdRXh302LLNR"
        }
    ]
}

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

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/notes/<id>/relations?locationId=<LOCATIONID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "type": "add",
  "relations": [
    {
      "objectKey": "contact",
      "recordId": "sx6wyHhbFdRXh302LLNR"
    }
  ]
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/notes/<id>/relations?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .header("Content-Type", "application/json")
  .body("{\"type\":\"add\",\"relations\":[{\"objectKey\":\"contact\",\"recordId\":\"sx6wyHhbFdRXh302LLNR\"}]}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/notes/<id>/relations?locationId=<LOCATIONID>"
  payload := strings.NewReader(`{
  "type": "add",
  "relations": [
    {
      "objectKey": "contact",
      "recordId": "sx6wyHhbFdRXh302LLNR"
    }
  ]
}`)
  req, _ := http.NewRequest("PUT", 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/notes/<id>/relations?locationId=<LOCATIONID>")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"
request["Content-Type"] = "application/json"
request.body = '{
  "type": "add",
  "relations": [
    {
      "objectKey": "contact",
      "recordId": "sx6wyHhbFdRXh302LLNR"
    }
  ]
}'

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

**PowerShell**

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

$body = '{
  "type": "add",
  "relations": [
    {
      "objectKey": "contact",
      "recordId": "sx6wyHhbFdRXh302LLNR"
    }
  ]
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/notes/<id>/relations?locationId=<LOCATIONID>' -Method 'PUT' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
