# Create Analytics Page Share

Share a page with one target. A member gets an email about the new share. A guest is someone outside your organization: they can only view, and they get an email with a link that works for 30 days and asks for a code sent to that address. Invite a guest only when that is meant. meta.emailed says whether anyone was emailed.

`POST https://connect.mindcloud.co/v2/analytics/pages/:pageId/shares`

Permissions: `analytics:page:edit`.

## Parameters

### Path

- `pageId` (string, required): The page id, from List Analytics Pages.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. Here a key acts in another organization only as one of its members: with "Use this key across all of your organizations" on, in an organization its creator belongs to with a role. Child organizations and MindCloud staff access do not reach this endpoint. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Body

- `targetType` (string, required): user, organization, role, team or guest (pages only).
  Who the share is for.
  Allowed values:
    - `user`: One member of the organization.
    - `organization`: Everyone in the organization.
    - `role`: Every member whose role is this one, now and later.
    - `team`: Every member of this team, now and later.
    - `guest`: A person outside the organization, by email. View only, pages only. They get an email with a link that works for 30 days and asks for a code sent to that address.
- `permission` (string, required): view or edit.
  What they can do. A guest can only view.
  Allowed values:
    - `view`: Can open it.
    - `edit`: Can open and edit it, as their role allows.
- `userId` (string): For user: the member, from List Members.
- `email` (string): For user: the member's email instead of userId. For guest: the address to invite.
  For user: the member's email, in place of userId. For guest: the address to invite.
- `roleId` (string): For role: the role, from List Roles.
- `teamId` (string): For team: the team, from List Teams.

## Example request

```bash
curl --request POST \
  --url 'https://connect.mindcloud.co/v2/analytics/pages/Pq7Lm2Xc9RtA/shares' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "targetType": "user",
  "permission": "view",
  "userId": "user_2wXk9Lm4Pq7Rz3Ts8Vb1Nc6Hd",
  "email": "ana@acme.com",
  "roleId": "Rl5wB9cF3hJp",
  "teamId": "tm_Q8dL2vN6tRwe"
}'
```

## Response fields

- `id` (string): The share's id.
- `targetType` (string): Who it is for.
  Allowed values:
    - `user`: One member of the organization.
    - `organization`: Everyone in the organization.
    - `role`: Every member whose role is this one, now and later.
    - `team`: Every member of this team, now and later.
    - `guest`: A person outside the organization, by email. View only, pages only. They get an email with a link that works for 30 days and asks for a code sent to that address.
- `permission` (string): What they can do.
  Allowed values:
    - `view`: Can open it.
    - `edit`: Can open and edit it, as their role allows.
- `userId` (string): For user: the member, from List Members. Null otherwise.
- `name` (string): For user: the member's name. Null otherwise.
- `email` (string): For user: the member's email. For guest: the guest's address. Null otherwise.
- `roleId` (string): For role: the role, from List Roles. Null otherwise.
- `roleName` (string): For role: the role's name. Null otherwise.
- `teamId` (string): For team: the team, from List Teams. Null otherwise.
- `teamName` (string): For team: the team's name. Null otherwise.
- `viaFolderId` (string): On a page: the folder this share comes from (from List Analytics Folders), when the page inherits it. Change it on that folder. Null for a share on the page itself.
- `viaFolderName` (string): The name of the folder it comes from. Null when it is the page's own.
- `createdOn` (date): When it was shared.
- `updatedOn` (date): When it last changed.
