# Working with invitations

This page describes how to create workflows for sending and withdrawing connection requests, and retrieving, accepting, and ignoring invitations on LinkedIn.

## Sending connection request

To send a connection request from your account to another person, you need to include [`st.sendConnectionRequest`](/docs/action-st-send-connection-request) action in your workflow. Here's an example:

**Workflow:**

```json
{
  "actionType": "st.sendConnectionRequest",
  "personUrl": "https://www.linkedin.com/in/person1",
  "note": "Hi, I’d like to connect with you to discuss potential collaboration.",
  "email": "example1@gmail.com"
}
```

**Completion:**

```json
{
  "actionType": "st.sendConnectionRequest",
  "success": true
}
```

## Withdrawing connection request

To withdraw the connection request sent from your account, you need to include [`st.withdrawConnectionRequest`](/docs/action-st-withdraw-connection-request) action in your workflow. Here's an example:

**Workflow:**

```json
{
  "actionType": "st.withdrawConnectionRequest",
  "personUrl": "https://www.linkedin.com/in/person1",
  "unfollow": true
}
```

**Completion:**

```json
{
  "actionType": "st.withdrawConnectionRequest",
  "success": true
}
```

## Retrieving pending connection requests

To retrieve a list of pending connection requests sent from your account, you need to include [`st.retrievePendingRequests`](/docs/action-st-retrieve-pending-requests) action in your workflow. Here's an example:

**Workflow:**

```json
{
  "actionType": "st.retrievePendingRequests"
}
```

**Completion:**

```json
{
  "actionType": "st.retrievePendingRequests",
  "success": true,
  "data": [
    {
      "name": "John Doe",
      "publicUrl": "https://www.linkedin.com/in/johndoe",
      "headline": "Founder & CEO at Example Company"
    },
    {
      "name": "Jane Smith",
      "publicUrl": "https://www.linkedin.com/in/janesmith",
      "headline": "CTO at Tech Solutions"
    },
    {
      "name": "Carlos Santos",
      "publicUrl": "https://www.linkedin.com/in/carlossantos",
      "headline": "Product Manager at Startup Hub"
    }
  ]
}
```

## Retrieving invitations

Use [`st.retrieveInvitations`](/docs/action-st-retrieve-invitations) to read all incoming connection, company-follow, and newsletter-subscription invitations from the invitation manager. The action is root-only and does not support `then`.

> 💡 To react to new connection requests as they arrive instead of polling this action on a schedule, enable [network monitoring](/docs/monitoring-network) with [`st.syncNetwork`](/docs/action-st-sync-network) and consume `connectionRequestReceived` events.

**Workflow:**

```json
{
  "actionType": "st.retrieveInvitations"
}
```

**Completion:**

```json
{
  "actionType": "st.retrieveInvitations",
  "success": true,
  "data": [
    {
      "invitationType": "connect",
      "name": "John Doe",
      "publicUrl": "https://www.linkedin.com/in/johndoe",
      "headline": "Founder & CEO at Example Company",
      "note": "I would like to connect."
    },
    {
      "invitationType": "companyFollow",
      "name": "Jane Smith",
      "publicUrl": "https://www.linkedin.com/in/janesmith",
      "companyUrl": "https://www.linkedin.com/company/example-company",
      "companyName": "Example Company"
    },
    {
      "invitationType": "newsletterSubscribe",
      "name": "Carlos Santos",
      "publicUrl": "https://www.linkedin.com/in/carlossantos",
      "newsletterUrl": "https://www.linkedin.com/newsletters/example-1234567890",
      "newsletterName": "Example Newsletter"
    }
  ]
}
```

Use the type-specific URL from each item when accepting or ignoring it:

| `invitationType`      | Required target                                 |
| --------------------- | ----------------------------------------------- |
| `connect`             | `personUrl`, using the item's `publicUrl` value |
| `companyFollow`       | `companyUrl`                                    |
| `newsletterSubscribe` | `newsletterUrl`                                 |

## Accepting an invitation

Use [`st.acceptInvitation`](/docs/action-st-accept-invitation) with the invitation type and exactly one matching target URL.

```json
{
  "actionType": "st.acceptInvitation",
  "invitationType": "connect",
  "personUrl": "https://www.linkedin.com/in/johndoe"
}
```

For a company-follow invitation:

```json
{
  "actionType": "st.acceptInvitation",
  "invitationType": "companyFollow",
  "companyUrl": "https://www.linkedin.com/company/example-company"
}
```

For a newsletter-subscription invitation:

```json
{
  "actionType": "st.acceptInvitation",
  "invitationType": "newsletterSubscribe",
  "newsletterUrl": "https://www.linkedin.com/newsletters/example-1234567890"
}
```

A successful completion contains `"success": true` and no data.

## Ignoring an invitation

[`st.ignoreInvitation`](/docs/action-st-ignore-invitation) uses the same target contract:

```json
{
  "actionType": "st.ignoreInvitation",
  "invitationType": "connect",
  "personUrl": "https://www.linkedin.com/in/johndoe"
}
```

Change `invitationType` and the URL field together for company-follow or newsletter-subscription invitations. A successful completion contains `"success": true` and no data.

> This page provides examples of [workflows](/docs/building-workflows) and their [completions](/docs/executing-workflows). For detailed constraints, parameters, and results, refer to the corresponding [action documentation pages](/docs/actions-overview).
