# Hosted sessions & pages
URL: https://docs.awellhealth.com/api-reference/reference/hosted-sessions

> For the complete documentation index, see [llms.txt](https://docs.awellhealth.com/llms.txt).



Start and complete Awell-hosted sessions and hosted pages for stakeholders to complete activities.

## Queries [#queries]

### `hostedPagesLink` [#hostedpageslink]

Returns the hosted pages link for a stakeholder in a care flow.

**Arguments**

| Argument         | Type      | Required | Description               |
| ---------------- | --------- | -------- | ------------------------- |
| `pathway_id`     | `String!` | Yes      | The ID of the care flow   |
| `stakeholder_id` | `String!` | Yes      | The ID of the stakeholder |

**Returns:** `HostedPagesLinkPayload!`

**Example**

```graphql
query HostedPagesLink($pathway_id: String!, $stakeholder_id: String!) {
  hostedPagesLink(pathway_id: $pathway_id, stakeholder_id: $stakeholder_id) {
    code
    hosted_pages_link {
      id
      pathway_id
      stakeholder_id
      url
    }
    success
  }
}
```

Variables:

```json
{
  "pathway_id": "<string>",
  "stakeholder_id": "<string>"
}
```

### `hostedPagesLinks` [#hostedpageslinks]

Returns the hosted pages links for all stakeholders in a care flow.

**Arguments**

| Argument     | Type      | Required | Description             |
| ------------ | --------- | -------- | ----------------------- |
| `pathway_id` | `String!` | Yes      | The ID of the care flow |

**Returns:** `HostedPagesLinksPayload!`

**Example**

```graphql
query HostedPagesLinks($pathway_id: String!) {
  hostedPagesLinks(pathway_id: $pathway_id) {
    code
    hosted_pages_links {
      id
      pathway_id
      stakeholder_definition_id
      stakeholder_id
      stakeholder_label
      url
    }
    success
  }
}
```

Variables:

```json
{
  "pathway_id": "<string>"
}
```

### `hostedSession` [#hostedsession]

Returns the current hosted session, including its branding, metadata, and session details.

**Returns:** `HostedSessionPayload!`

**Example**

```graphql
query HostedSession {
  hostedSession {
    branding {
      accent_color
      custom_theme
      hosted_page_auto_progress
      hosted_page_autosave
      hosted_page_title
      logo_url
    }
    code
    metadata {
      pathway_definition_id
      tenant_id
    }
    session {
      cancel_url
      created_at
      expires_at
      id
      organization_slug
      pathway_id
      stakeholder {
        id
        name
        type
      }
      status
      success_url
      tracking {
        custom
        utm_campaign
        utm_content
        utm_medium
        utm_source
        utm_term
      }
      user_context {
        stytch_member_email
        stytch_member_id
      }
    }
    success
  }
}
```

### `hostedSessionActivities` [#hostedsessionactivities]

Returns the activities for the current hosted session.

**Arguments**

| Argument                      | Type      | Required | Description                                         |
| ----------------------------- | --------- | -------- | --------------------------------------------------- |
| `only_stakeholder_activities` | `Boolean` | No       | Whether to return only the stakeholder's activities |

**Returns:** `HostedSessionActivitiesPayload!`

**Example**

```graphql
query HostedSessionActivities($only_stakeholder_activities: Boolean) {
  hostedSessionActivities(only_stakeholder_activities: $only_stakeholder_activities) {
    activities {
      action
      action_component {
        definition_id
        release_id
        title
      }
      container_name
      context {
        action_id
        agent_config_id
        agent_id
        agent_thread_id
        instance_id
        pathway_id
        run_id
        step_id
        track_id
      }
      date
      expires_at
      form {
        definition_id
        id
        key
        metadata
        release_id
        title
        trademark
      }
      form_display_mode
      icon_url
      id
      isUserActivity
      metadata
      public
      reference_id
      reference_type
      resolution
      session_id
      status
      stream_id
    }
    code
    success
  }
}
```

Variables:

```json
{
  "only_stakeholder_activities": true
}
```

## Mutations [#mutations]

### `completeSession` [#completesession]

Completes a hosted session.

**Arguments**

| Argument | Type                    | Required | Description                                   |
| -------- | ----------------------- | -------- | --------------------------------------------- |
| `input`  | `CompleteSessionInput!` | Yes      | The input identifying the session to complete |

**Returns:** `CompleteSessionPayload!`

**Example**

```graphql
mutation CompleteSession($input: CompleteSessionInput!) {
  completeSession(input: $input) {
    code
    session {
      cancel_url
      created_at
      expires_at
      id
      organization_slug
      pathway_id
      stakeholder {
        id
        name
        type
      }
      status
      success_url
      tracking {
        custom
        utm_campaign
        utm_content
        utm_medium
        utm_source
        utm_term
      }
      user_context {
        stytch_member_email
        stytch_member_id
      }
    }
    success
  }
}
```

Variables:

```json
{
  "input": {
    "session_id": "<string>"
  }
}
```

### `startHostedActivitySession` [#starthostedactivitysession]

Starts a hosted activity session for a stakeholder in a care flow.

**Arguments**

| Argument | Type                               | Required | Description                                        |
| -------- | ---------------------------------- | -------- | -------------------------------------------------- |
| `input`  | `StartHostedActivitySessionInput!` | Yes      | The input for starting the hosted activity session |

**Returns:** `StartHostedActivitySessionPayload!`

**Example**

```graphql
mutation StartHostedActivitySession($input: StartHostedActivitySessionInput!) {
  startHostedActivitySession(input: $input) {
    code
    language
    organization_slug
    session_id
    session_url
    success
    tracking {
      custom
      utm_campaign
      utm_content
      utm_medium
      utm_source
      utm_term
    }
    user_context {
      stytch_member_email
      stytch_member_id
    }
  }
}
```

Variables:

```json
{
  "input": {
    "pathway_id": "<string>",
    "stakeholder_id": "<string>"
  }
}
```

### `startHostedActivitySessionViaHostedPagesLink` [#starthostedactivitysessionviahostedpageslink]

Starts a hosted activity session from a hosted pages link.

**Arguments**

| Argument | Type                                                 | Required | Description                                                                |
| -------- | ---------------------------------------------------- | -------- | -------------------------------------------------------------------------- |
| `input`  | `StartHostedActivitySessionViaHostedPagesLinkInput!` | Yes      | The input for starting the hosted activity session via a hosted pages link |

**Returns:** `StartHostedActivitySessionPayload!`

**Example**

```graphql
mutation StartHostedActivitySessionViaHostedPagesLink($input: StartHostedActivitySessionViaHostedPagesLinkInput!) {
  startHostedActivitySessionViaHostedPagesLink(input: $input) {
    code
    language
    organization_slug
    session_id
    session_url
    success
    tracking {
      custom
      utm_campaign
      utm_content
      utm_medium
      utm_source
      utm_term
    }
    user_context {
      stytch_member_email
      stytch_member_id
    }
  }
}
```

Variables:

```json
{
  "input": {
    "hosted_pages_link_id": "<string>"
  }
}
```

### `startHostedPathwaySession` [#starthostedpathwaysession]

Start a hosted pathway session for a patient uniquely identified by patient\_id or patient\_identifier. If neither patient\_id or patient\_identifier is provided, a new anonymous patient will be created.

**Arguments**

| Argument | Type                              | Required | Description                                         |
| -------- | --------------------------------- | -------- | --------------------------------------------------- |
| `input`  | `StartHostedPathwaySessionInput!` | Yes      | The input for starting the hosted care flow session |

**Returns:** `StartHostedPathwaySessionPayload!`

**Example**

```graphql
mutation StartHostedPathwaySession($input: StartHostedPathwaySessionInput!) {
  startHostedPathwaySession(input: $input) {
    code
    organization_slug
    pathway_id
    session_id
    session_url
    stakeholder {
      id
      name
      type
    }
    success
    tracking {
      custom
      utm_campaign
      utm_content
      utm_medium
      utm_source
      utm_term
    }
    user_context {
      stytch_member_email
      stytch_member_id
    }
  }
}
```

Variables:

```json
{
  "input": {
    "pathway_definition_id": "<string>"
  }
}
```

### `startHostedPathwaySessionFromLink` [#starthostedpathwaysessionfromlink]

Starts a hosted care flow session from a link.

**Arguments**

| Argument | Type                                      | Required | Description                                                     |
| -------- | ----------------------------------------- | -------- | --------------------------------------------------------------- |
| `input`  | `StartHostedPathwaySessionFromLinkInput!` | Yes      | The input for starting the hosted care flow session from a link |

**Returns:** `StartHostedPathwaySessionFromLinkPayload!`

**Example**

```graphql
mutation StartHostedPathwaySessionFromLink($input: StartHostedPathwaySessionFromLinkInput!) {
  startHostedPathwaySessionFromLink(input: $input) {
    code
    organization_slug
    session_url
    success
    tracking {
      custom
      utm_campaign
      utm_content
      utm_medium
      utm_source
      utm_term
    }
  }
}
```

Variables:

```json
{
  "input": {
    "id": "<string>"
  }
}
```
