# sendMessage

This method allows you to send a message to a person.

```typescript
try {
  const workflow = await linkedapi.sendMessage.execute({
    personUrl: "https://www.linkedin.com/in/john-doe",
    text: "Hi John! How are you?",
    manageConversation: { operation: "archive" }
  });

  const { errors } = await linkedapi.sendMessage.result(workflow.workflowId);

  // The list of possible execution errors is below
  if (errors && errors.length > 0) {
    console.warn('Workflow completed with execution errors:');
    errors.forEach(error => {
      console.warn(` - Type: ${error.type}, Message: ${error.message}`);
    });
  } else {
    console.log('Message sent successfully.');
  }
} catch (e) {
  // A list of all critical errors can be found here:
  // https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
  if (e instanceof LinkedApiError) {
    console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
  } else {
    console.error('An unexpected, non-API error occurred:', e);
  }
}
```

```python
from linkedapi import SendMessageParams, SendMessageManageConversation, LinkedApiError

try:
    workflow = linkedapi.send_message.execute(
        SendMessageParams(
            person_url="https://www.linkedin.com/in/john-doe",
            text="Hi John! How are you?",
            manage_conversation=SendMessageManageConversation(operation="archive"),
        )
    )

    result = linkedapi.send_message.result(workflow.workflow_id)
    errors = result.errors

    # The list of possible execution errors is below
    if errors:
        print("Workflow completed with execution errors:")
        for error in errors:
            print(f" - Type: {error.type}, Message: {error.message}")
    else:
        print("Message sent successfully.")
except LinkedApiError as e:
    # A list of all critical errors can be found here:
    # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
    print(f"Critical Error - Type: {e.type}, Message: {e.message}")
except Exception as error:
    print("An unexpected, non-API error occurred:", error)
```

## Params

- `personUrl`  – [public or hashed](/faq/what-are-hashed-url-and-public-url) LinkedIn URL of the person you want to send a message to.
- `threadId` (optional) – identifier of an existing conversation thread to reply into, as returned by [`pollInbox`](/sdks/poll-inbox) or [`pollConversations`](/sdks/poll-conversations). Provide either `personUrl` or `threadId`; if both are given, `threadId` takes precedence.
- `text`  – message text, must be up to **1900** characters.
- `manageConversation` (optional) – manage the conversation right after the message is sent. Provide `{ operation }` (one of `archive`, `unarchive`, `star`, `unstar`, `mute`, `unmute`); it acts on the same thread, so no `threadId` is needed.

> Replying by `threadId` sends the message directly into a known conversation, which is convenient when reacting to an inbox event without resolving the person's profile URL first.

## Data

The method doesn't return any data.

## Errors

- `personNotFound` – provided URL is not an existing LinkedIn person.
- `selfProfileNotAllowed` – action cannot be performed on your own profile.
- `messagingNotAllowed` – sending a message to the person is not allowed. This could happen for several reasons:
  - You are not connected to the person.
  - LinkedIn has restricted your ability to send messages to the person, for example, due to reaching message limits or the person’s privacy settings.
