# Welcome

TNID makes creating your personal and business identity a breeze. Connect with people and companies you care about, and manage your preferences with them in one simple to use interface.

### Document Formatting <a href="#document-formatting" id="document-formatting"></a>

We generally format our API documents in the following manner:

1. Overview: the purpose of the end-point
2. Authentication: how to authenticate to the end-point
3. Method: details regarding the API method and examples.

All TNID APIs are GraphQL based. Throughout the documentation, we use common HTTP features such as HTTP verbs and HTTP status codes. Requests must be made via HTTPS (calls over plain HTTP will fail).

Happy coding!

### Jump right in!

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Company Authentication</strong></td><td>Learn how to login as a Company and use features available to businesses.</td><td></td><td></td><td><a href="/authentication/company-authentication">Company Authentication</a></td></tr><tr><td><strong>User Authentication</strong></td><td>Login as a User and use features available to individuals, including spam reporting.</td><td></td><td></td><td><a href="/authentication/user-authentication">User Authentication</a></td></tr></tbody></table>


# Getting Started Guide

## TNID API — Getting Started

### 0) What you’ll use

* **Auth endpoints:** `/auth/create_user_otp`, `/auth/token`
* **GraphQL endpoints:** `/user` (for people) and `/company` (for businesses)
* You can try everything with Postman first. [docs.tnid.com+1](https://docs.tnid.com/getting-started/quickstart-1?utm_source=chatgpt.com)

***

### 1) Create (or claim) your individual profile

Think of this as “getting your user login.”

**Step A — Request a one-time code (OTP)**\
Send your phone number (and, if you’re creating a new user, first/last name + email) to **`/auth/create_user_otp`**. You’ll receive an OTP. [docs.tnid.com](https://docs.tnid.com/getting-started/quickstart-1?utm_source=chatgpt.com)

**Step B — Exchange the OTP for a Bearer token**\
Send your **`telephone_number`** and **`otp_code`** to **`/auth/token`**.\
You’ll get an **`access_token`** (Bearer token) that lets you call the **`/user`** GraphQL API. Save it securely. [docs.tnid.com](https://docs.tnid.com/getting-started/quickstart-1?utm_source=chatgpt.com)

**Optional — Update your user profile**\
With your user token, call the **`/user`** GraphQL mutation `updateUser` to set things like `firstName`, `lastName`, `username`, or `aboutMe`. [docs.tnid.com](https://docs.tnid.com/user/update-user-profile)

> Tip: If you prefer a point-and-click test, open Postman → choose **GraphQL** → paste your token into the **Authorization: Bearer** header → target **`/user`**. [docs.tnid.com](https://docs.tnid.com/getting-started/accessing-via-postman-graphql-schema-examples?utm_source=chatgpt.com)

***

### 2) Create your company (as that user)

Once you have a user token, you can make a company and (optionally) mint credentials for it.

**Step A — Create the company profile**\
Call the **`createCompany`** mutation on **`/user`** and provide basics (`legalName`, `profileName`, optional `brandName`, `taxId`, etc.).\
If you include **`provisionCompanyClientSecret: true`**, TNID will also return a **`clientId`/`clientSecret`** you can use for company-level API calls. [docs.tnid.com](https://docs.tnid.com/user/company-features/create-company-profile)

**Step B — (Alternative) Generate company credentials later**\
If you didn’t provision in step A, you can still create client credentials from the TNID UI (Client Secrets) and then exchange **`client_id`/`client_secret`** at **`/auth/token`** to get a **company Bearer token**. Use that token with **`/company`** GraphQL. [docs.tnid.com](https://docs.tnid.com/getting-started/quickstart?utm_source=chatgpt.com)

**Optional — Update your company profile**\
Use the **`updateCompany`** mutation to adjust `legalName`, `brandName`, `yearFounded`, `aboutUs`, etc. (with your **company** token). [docs.tnid.com](https://docs.tnid.com/company/update-company-profile?utm_source=chatgpt.com)

***

### 3) Common “first calls” after setup

**Find companies (to connect with or avoid duplicates)**\
Query `companies` (name, taxId, email, telephoneNumber, webpage) via **`/company`**. Handy when checking if your org already exists. [docs.tnid.com](https://docs.tnid.com/company/search-companies?utm_source=chatgpt.com)

**Invite another company or request a B2B connection**

* Invite by details (e.g., legal name + a rep’s email) using `createB2bInvite`. [docs.tnid.com](https://docs.tnid.com/company/invite-company?utm_source=chatgpt.com)
* Or send a connection request by `invitedCompanyId` with `createB2bConnectionRequest`. [docs.tnid.com](https://docs.tnid.com/company/b2b-features/send-b2b-connection-request?utm_source=chatgpt.com)

**Search for people / see your consumer connections**\
Use `searchPeople` and `b2cConnections` on **`/company`**. [docs.tnid.com+1](https://docs.tnid.com/company/b2c-features/search-people?utm_source=chatgpt.com)

**User-side spam reporting (popular early integration)**\
As a user, call `createSpamReport` / `listSpamReports` on **`/user`** to help your customers report unwanted communications. [docs.tnid.com+1](https://docs.tnid.com/user/spam-reporting-features/create-spam-report?utm_source=chatgpt.com)

***

### 4) Where to point your requests

* **GraphQL**
  * People: **`/user`**
  * Companies: **`/company`** [docs.tnid.com](https://docs.tnid.com/?utm_source=chatgpt.com)
* **Auth**
  * OTP: **`/auth/create_user_otp`**
  * Token exchange: **`/auth/token`** [docs.tnid.com+1](https://docs.tnid.com/getting-started/quickstart-1?utm_source=chatgpt.com)
* **Postman quick start** (browse schema + run mutations with your Bearer token). [docs.tnid.com](https://docs.tnid.com/getting-started/accessing-via-postman-graphql-schema-examples?utm_source=chatgpt.com)

***

### 5) Quick mental model

1. **Become a user** (OTP → token → `/user`).
2. **Create your company** (as that user) and **mint company creds**.
3. **Act as the company** (company token → `/company`) for B2B/B2C, profile updates, invites, etc. [docs.tnid.com+1](https://docs.tnid.com/user/company-features/create-company-profile)


# Company Authentication

Learn how to get your Company TNID client key and secret to authenticate into the GraphQL API.

<figure><img src="https://218732174-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfPazwA5iPiTPgaPvkQZx%2Fuploads%2FuwD0yvcflCzURsLbk0vD%2FScreenshot%202024-09-30%20at%201.43.43%E2%80%AFPM.png?alt=media&amp;token=1f241e8f-689d-4972-aea3-518e2593b360" alt=""><figcaption><p>Screenshot of Client Secrets section in GUI</p></figcaption></figure>

Company users of TNID are currently able to generate Client Secrets so that they can access the API. To create a Company, first register as an Individual, and then create a Company associated with your Individual profile. Then, assume the role of your Company and click "New Client Secret" in order to create your credentials.

{% hint style="danger" %}
You are only allowed to view your Client Secret value at creation, so please ensure you save it someplace safe (e.g. 1Password or your environment variables).  You will not be able to see it once you close the pop-up (however, you can always create a new Client Secret.
{% endhint %}

{% hint style="warning" %}
We do not expire tokens or force password resets at any time. We follow the latest NIST guidelines and believe in a strong, lengthy secure password protocol. Create new Client Secrets if you believe there is evidence of a compromise.
{% endhint %}

### Generate Your Bearer Token

The below URLs are available to create your API token, depending on your environment:

{% embed url="<https://api.staging.v2.tnid.com/auth/token>" %}
Staging Environment
{% endembed %}

{% embed url="<https://api.demo.v2.tnid.com/auth/token>" %}
Demo / Beta Environment
{% endembed %}

Simply pass the client\_id and client\_secret data to generate your Bearer token for future API requests:

```
{
   "client_id": CLIENT_ID_VALUE,
   "client_secret": CLIENT_SECRET_VALUE
}
```

Use the access\_token from the response to interact with the GraphQL api at /company.

### Example Company authentication using various languages

{% tabs %}
{% tab title="Python" %}

```python
import requests

def get_bearer_token(client_id, client_secret):
    url = "https://api.staging.v2.tnid.com/auth/token"
    
    # Define the headers and body of the request
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    }
    
    # The payload or data to be sent in the POST request
    data = {
        "client_id": client_id,
        "client_secret": client_secret
    }
    
    # Make the POST request to the token endpoint
    response = requests.post(url, headers=headers, data=data)
    
    # Check if the request was successful
    if response.status_code == 200:
        # Parse the response and extract the access token
        token_data = response.json()
        return token_data.get("access_token")
    else:
        raise Exception(f"Failed to retrieve token: {response.status_code} {response.text}")

# Example usage:
client_id = "your_client_id"      # Replace with your actual client ID
client_secret = "your_client_secret"  # Replace with your actual client secret

token = get_bearer_token(client_id, client_secret)
print("Bearer Token:", token)
```

{% endtab %}

{% tab title="Coming Soon" %}

{% endtab %}
{% endtabs %}


# User Authentication

Learn how to get your TNID client key and secret to authenticate into the GraphQL API.

Users of TNID (as opposed to Companies) are currently able to generate an access token using an OTP to their telephone number.

{% hint style="warning" %}
We do not expire tokens or force password resets at any time. We follow the latest NIST guidelines and believe in a strong, lengthy secure password protocol. Create new Client Secrets if you believe there is evidence of a compromise.
{% endhint %}

### Generate Your Access Token

The below URLs are available to create your API token, depending on your environment:

{% embed url="<https://api.staging.v2.tnid.com/auth/create_user_otp>" %}
Staging Environment
{% endembed %}

{% embed url="<https://api.demo.v2.tnid.com/auth/create_user_otp>" %}
Demo Environment
{% endembed %}

Make a request to /auth/create\_user\_otp with the telephone\_number of an existing user or a not existing user and optional information:

```
{
   "telephone_number": "3024343434333",
   "first_name": "John",
   "last_name": "Doe",
   "email": "email@address.com"
}

```

Make a request with the telephone\_number and the received otp\_code to /auth/token:

```
{
   "telephone_number": "3024343434333",
   "otp_code": "698125"
}

```

Use the access\_token from the response to interact with the GraphQL api at /user.

## Example Code

{% tabs %}
{% tab title="Python" %}

```
import requests

# courtesy of https://github.com/PockyBum522/
# You will need to run this as step one, after which the user will receive an OTP in their email.
# With that OTP, you can request the actual token
def get_bearer_token_otp_for_existing_user(user_phone_number):
    url = "https://api.staging.v2.tnid.com/auth/create_user_otp"

    # Define the headers and body of the request
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    }

    # The payload or data to be sent in the POST request
    data = {
        "telephone_number": user_phone_number
    }

    # Make the POST request to the token endpoint
    response = requests.post(url, headers=headers, data=data)

    # Check if the request was successful
    if response.status_code == 200:
        print(f"Response OK when requesting OTP: {response.status_code} {response.text}")
    else:
        raise Exception(f"Failed to request OTP: {response.status_code} {response.text}")


# This is step two, to request the bearer token once you have an OTP
def get_bearer_token(user_phone_number, otp):
    url = "https://api.staging.v2.tnid.com/auth/token"

    # Define the headers and body of the request
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    }

    # The payload or data to be sent in the POST request
    data = {
        "telephone_number": user_phone_number,
        "otp_code": otp
    }

    # Make the POST request to the token endpoint
    response = requests.post(url, headers=headers, data=data)

    # Check if the request was successful
    if response.status_code == 200:
        # Parse the response and extract the access token
        token_data = response.json()
        return token_data.get("access_token")
    else:
        raise Exception(f"Failed to retrieve token: {response.status_code} {response.text}")


# Create a new user, after which you will have to request their OTP, then bearer token using the other provided functions
def create_new_user(phone_number, first_name, last_name, email):
    url = "https://api.staging.v2.tnid.com/auth/create_user_otp"

    # Define the headers of the request
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    }

    # The payload or data to be sent in the POST request
    data = {
        "telephone_number": phone_number,
        "first_name": first_name,
        "last_name": last_name,
        "email": email
    }

    # Make the POST request to the token endpoint
    response = requests.post(url, headers=headers, data=data)

    # Check if the request was successful
    if response.status_code == 200:
        print(f"Response OK when creating new user: {response.status_code} {response.text}")
    else:
        raise Exception(f"Failed to create new user: {response.status_code} {response.text}")


query_phone_number = "14075554530"

get_bearer_token_otp_for_existing_user(query_phone_number)

print("Please check your email and enter the OTP here: ")
otp_from_email = input()

bearer_token = get_bearer_token(query_phone_number, otp_from_email)
print("Bearer Token: ", bearer_token)

# OR:
# new_user_phone_number = "15555555555"
#
# create_new_user(new_user_phone_number, "Firstname", "Lastname", "user@email.com")
#
# get_bearer_token_otp_for_existing_user(new_user_phone_number)
#
# print("Please check your email and enter the OTP here: ")
# otp_from_email = input()
#
# bearer_token = get_bearer_token(new_user_phone_number, otp_from_email)
# print("Bearer Token: ", bearer_token)
```

{% endtab %}
{% endtabs %}


# Refresh Token

* Make a request to /auth/refresh-token with a refresh\_token.
* Accepts a valid refresh\_token and issues a new access\_token (7 days validity) and a refresh\_token (30 days validity).
* An access token can be used to access restricted resources. A refresh token can only be used to refresh tokens.

```
{
   "access_token": "access_token here",
   "refresh_token": "refresh_token here"
}
```


# Accessing via Postman / GraphQL Schema examples

## Postman

Once you have generated your Bearer token, you can access the GraphQL schema easily using Postman. Simply take your generated token, and create a new request using the GraphQL feature:

<figure><img src="https://218732174-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfPazwA5iPiTPgaPvkQZx%2Fuploads%2FvLHFwqwTq4ERIzyWwC2Q%2Fimage.png?alt=media&amp;token=6f47b718-da6d-41aa-9c4b-563ed5e1b6a6" alt=""><figcaption><p>Select GraphQL from the dropdown.</p></figcaption></figure>

<figure><img src="https://218732174-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfPazwA5iPiTPgaPvkQZx%2Fuploads%2F2dROSXRXFbIztkzNl1mn%2FScreenshot%202024-10-16%20at%208.18.19%E2%80%AFAM.png?alt=media&amp;token=0b525ce5-d3c6-48a0-ad9d-a9422c10ad78" alt=""><figcaption><p>Authenticate using your generated Bearer token.</p></figcaption></figure>

Load the GraphQL schema by entering the URL (<https://api.staging.v2.tnid.com/company> for example, for the /company endpoints), and then press "Use GraphQL Introspection" on the Schema tab.

<figure><img src="https://218732174-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfPazwA5iPiTPgaPvkQZx%2Fuploads%2F7uUbUnlsrZF76S7rYped%2FScreenshot%202024-10-16%20at%208.20.13%E2%80%AFAM.png?alt=media&amp;token=63f2ffb6-eec2-400b-a6e9-ca581f5793c8" alt=""><figcaption><p>Press "Use GraphQL Introspection" to load the schema.</p></figcaption></figure>

<figure><img src="https://218732174-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfPazwA5iPiTPgaPvkQZx%2Fuploads%2FP2FchM9frYc6trduqiuJ%2FScreenshot%202024-10-16%20at%208.20.26%E2%80%AFAM.png?alt=media&amp;token=e1c8e760-8fc5-4000-801b-f0d96d6dcdfb" alt=""><figcaption></figcaption></figure>

The schema should now be accessible via Postman.

## Example Code to access GraphQL Schema

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
import pprint
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def get_full_company_endpoint_schema(bearer_token):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    # Make a valid query so that gql can fetch the full schema
    query = gql(
        """
        query (
            $name: String
            $taxId: String
            $email: String
            $telephoneNumber: String
            $webpage: String
            $limit: Int
          ) {
            companies (
            name: $name
            taxId: $taxId
            email: $email
            telephoneNumber: $telephoneNumber
            webpage: $webpage
            limit: $limit
            ) {
            id
            legalName
            brandName
            profileName
            taxId
            }
          }
        """
    )

    params = { "name": "schema query" }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)

        # Working with the schema GQL gave us from the server
        schema = client.introspection

        print(f"Response OK: {response}")

        # Pretty print out the schema to the console
        print("Schema: ")
        pprint.pp(schema)

        return response
    except Exception as e:
        print(f"Exception: {e}")


def get_full_user_endpoint_schema(bearer_token, query_name = None, tax_id = None, email = None, phone_number = None, webpage = None, limit_count = 10):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/user",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    # Make a valid query so that gql can fetch the full schema
    query = gql(
        """
        query (
            $channelType: SpamReportChannelType
            $issueType: SpamReportIssueType
            $includedStatus: SpamReportStatus
            $excludedStatus: SpamReportStatus
            $limit: Int
          ) {
            spamReports (
            channelType: $channelType
            issueType: $issueType
            includedStatus: $includedStatus
            excludedStatus: $excludedStatus
            limit: $limit
            ) {
            id
            fromNumber
            toNumber
            userNote
            messageContent
            channelType
            issueType
            status
            createdAt
            updatedAt
            timestamp
            metadata
            user {
                id
            }
            }
          }
        """
    )

    params = { "limit": 1 }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)

        # Working with the schema GQL gave us from the server
        schema = client.introspection

        print(f"Response OK: {response}")

        # Pretty print out the schema to the console
        print("Schema: ")
        pprint.pp(schema)

        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_company_token"
get_full_company_endpoint_schema(token)

# OR
# token = "your_user_token"
# get_full_user_endpoint_schema(token)
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# Search Companies

Search for one or more companies based on name, tax ID, website, or other fields.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

This endpoint will return a list of companies matching the query and in case queried props are visible to the querier, it will be possible to query by:

* ID
* Legal name (with name field)&#x20;
* Brand name (with name field)&#x20;
* Profile name (with name field)&#x20;
* TaxID&#x20;
* Telephone number&#x20;
* Email&#x20;
* Webpage (social media or other)&#x20;

Each result will return a list of companies. It is possible to pass a combination of queryable props.

```
query (
    $id: ID
    $name: String
    $taxId: String
    $email: String
    $telephoneNumber: String
    $webpage: String
    $limit: Int
    $metadata: JSON
  ) {
    companies (
      id: $id
      name: $name
      taxId: $taxId
      email: $email
      telephoneNumber: $telephoneNumber
      webpage: $webpage
      limit: $limit
      metadata: $metadata
    ) {
      id
      legalName
      brandName
      profileName
      taxId
      yearFounded
      aboutUs
      metadata
      verified
      logoUrl
      verticalType {
        id
        displayName
        description
      }
      organizationType {
        id
        displayName
      }
      addresses {
        city
        country
        state
        street
        types
        zipCode
      }
      emails {
        email
      }
      telephoneNumbers {
        number
      }
      socialNetworks {
        type
        url
      }
      webpages {
        type
        url
      }
      specialties {
        description
        title
      }
      subscriptionTopics {
        id
        name
      }
      subscriptionSettings {
        enable_email
        enable_sms
        enable_voice
      }
    }

```

## Example Code

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def search_companies(bearer_token, query_name = None, tax_id = None, email = None, phone_number = None, webpage = None, limit_count = 10):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
        """
        query (
            $name: String
            $taxId: String
            $email: String
            $telephoneNumber: String
            $webpage: String
            $limit: Int
          ) {
            companies (
            name: $name
            taxId: $taxId
            email: $email
            telephoneNumber: $telephoneNumber
            webpage: $webpage
            limit: $limit
            ) {
            id
            legalName
            brandName
            profileName
            taxId
            }
          }
        """
    )

    params = { "name": query_name, "taxId": tax_id, "email": email, "telephoneNumber": phone_number, "webpage": webpage, "limit": limit_count }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK when searching companies: {response}")
        return response
    except Exception as e:
        print(f"Exception when searching companies: {e}")


# Example usage:
token = "your_company_token"
search_companies(token, "ACME")
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# Invite Company

Invite a company to join the TNID ecosystem.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

* As much as possible data should be included in the invitation model so the invitee can only verify and confirm entered data (of course, they can change if necessary)
* As part of the invitation, at least one person needs to be included in the invitation so that after they register they can take over the management of the newly created company
* Connection request needs to be confirmed/accepted by the newly created company legal representative.
* Most properties are flagged private so the newly created company data is not exposed

```json
mutation (
	$company: CompanyInput!
	$representatives: [InviteUserInput!]!
	$connectionType: B2bConnectionType!
  ) {
	createB2bInvite (
  	company: $company
  	representatives: $representatives
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedCompany {
    	id,
    	legalName,
    	brandName,
    	taxId
      }
    }
  }

```

## Example Code

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def invite_company(bearer_token, company_to_invite = None, company_representatives = None, connection_type = None):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
        """
            mutation (
                $company: CompanyInput!
                $representatives: [InviteUserInput!]!
                $connectionType: B2bConnectionType!
              ) {
                createB2bInvite (
                company: $company
                representatives: $representatives
                connectionType: $connectionType
                ) {
                id
                status
                type
                insertedAt
                respondedAt
                updatedAt
                company {
                    id
                }
                user {
                    id
                }
                invitedCompany {
                    id,
                    legalName,
                    brandName,
                    taxId
                  }
                }
              }
        """
    )

    params = { "company": company_to_invite, "representatives": company_representatives, "connectionType": connection_type }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
company_to_invite = { "legalName": "Acme Metals" }
company_representative = { "email": "user@acme-metals-domain.com", "first_name": "Jane", "last_name": "Smith" }

token = "your_company_token"
invite_company(token, company_to_invite, company_representative, "PARTNER")
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# List Organization Types

Used to list the different Organization types a Company can have.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

<pre><code><strong>query
</strong><strong>  {
</strong>  organizationTypes
  {
  id
  displayName
  }
}
</code></pre>

## Example Code

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def list_organization_types(bearer_token):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
            """
                query
                  {
                  organizationTypes
                  {
                  id
                  displayName
                  }
                }
            """
    )

    try:
        # Execute the query on the transport
        response = client.execute(query)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_company_token"
list_organization_types(token)
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# List Vertical Types

Used to list the different vertical types that a Company can have.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
query
	{
	verticalTypes
  	{
  	id
  	displayName
  	description
	}
  }

```

## Example Code

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def list_organization_types(bearer_token):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
            """
                query
                    {
                    verticalTypes
                    {
                    id
                    displayName
                    description
                    }
                  }
            """
    )

    try:
        # Execute the query on the transport
        response = client.execute(query)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_company_token"
list_organization_types(token)
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# Update Company Profile

Use this endpoint to update your company profile fields.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
 mutation (
    $legalName: String
    $brandName: String
    $profileName: String
    $taxId: String
    $yearFounded: Int
    $aboutUs: String
    $metadata: JSON
    $subscriptionTopics: [B2cSubscriptionTopicInput!]
    $subscriptionSettings: CompanySubscriptionSettingsInput
  ) {
    updateCompany (
      legalName: $legalName
      brandName: $brandName
      profileName: $profileName
      taxId: $taxId
      yearFounded: $yearFounded
      aboutUs: $aboutUs
      metadata: $metadata
      subscriptionTopics: $subscriptionTopics
      subscriptionSettings: $subscriptionSettings
    ) {
      id
      legalName
      brandName
      profileName
      taxId
      yearFounded
      aboutUs
      metadata
      subscriptionTopics {
        id
        name
        enable_email
        enable_sms
        enable_voice
      }
      subscriptionSettings {
        enable_email
        enable_sms
        enable_voice
      }
    }
  }

```

## Example Code

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def update_company_profile(bearer_token, legal_name = None, brand_name = None, profile_name = None, tax_id = None, year_founded = None, about_us = None, metadata = None):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
        """
             mutation (
                $legalName: String
                $brandName: String
                $profileName: String
                $taxId: String
                $yearFounded: Int
                $aboutUs: String
                $metadata: Json
              ) {
                updateCompany (
                legalName: $legalName
                brandName: $brandName
                profileName: $profileName
                taxId: $taxId
                yearFounded: $yearFounded
                aboutUs: $aboutUs
                metadata: $metadata
                ) {
                id
                legalName
                brandName
                profileName
                taxId
                yearFounded
                aboutUs
                metadata
                }
              }
        """
    )

    params = { "legalName": legal_name,
               "brandName": brand_name,
               "profileName": profile_name,
               "taxId": tax_id,
               "yearFounded": year_founded,
               "aboutUs": about_us,
               "metadata": metadata }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_company_token"
update_company_profile(token,
                       "Company new legal name",
                       "Company new brand name",
                       "Company new profile name",
                       "44-555555",
                       2003,
                       "New about us",
                       "{\"companyNumEmployees\": \"5\"}")
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# B2B Features


# Send B2B Connection Request

By providing the invited company ID and the connection type, a connection request will be sent to the invited company.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
mutation (
	$invitedCompanyId: ID!
	$connectionType: B2bConnectionType!
          ) {
	createB2bConnectionRequest (
  	invitedCompanyId: $invitedCompanyId
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedCompany {
    	id
      }
    }
  }

```


# List B2B Connections

Call returns list of connected companies and the relationship type(s) (client, vendor, partner, other)

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
query (
	$includedType: B2bConnectionType
	$excludedType: B2bConnectionType
	$limit: Int
  ) {
	b2bConnections (
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	type
  	createdAt
  	updatedAt
  	startedAt
  	company {
    	id
  	}
  	connectedCompany {
    	id
  	}
	}
  }

```

## Code Examples

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def list_b2b_connections(bearer_token, include_type = None, exclude_type = None, limit_count = 10):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
        """
            query (
                $includedType: B2bConnectionType
                $excludedType: B2bConnectionType
                $limit: Int
              ) {
                b2bConnect ions (
                includedType: $includedType
                excludedType: $excludedType
                limit: $limit
                ) {
                id
                type
                createdAt
                updatedAt
                startedAt
                company {
                    id
                }
                connectedCompany {
                    id
                }
                }
              }
        """
    )

    params = { "includedType": include_type, "excludedType": exclude_type, "limit": limit_count }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_company_token"
list_b2b_connections(token)
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# List Pending B2B Connection Requests

Returns a list of pending Company connection requests to your Company.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

* Returns a list of pending connection requests this company sent to other companies
* Includes company data, invitation status, and proposed connection type (vendor, client, partner..)

```
query (
	$invitedCompanyId: ID
	$includedType: B2bConnectionType
	$excludedType: B2bConnectionType
	$limit: Int
  ) {
	pendingB2bConnectionRequests (
  	invitedCompanyId: $invitedCompanyId
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
	}
  }

```


# Remove B2B Connection

Use the below mutation to remove existing B2B Connection(s).

```
mutation (
    $connectionId: ID!
  ) {
    removeB2bConnection (
      connectionId: $connectionId
    ) {
      id
      type
      createdAt
      updatedAt
      startedAt
      company {
        id
      }
      connectedCompany {
        id
      }
    }
  }

```


# Cancel B2B Connection Request

Cancels a B2B connection request you've sent.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

If a company wants to revoke a connection request it can choose from the list of pending requests and revoke it.

```
mutation (
	$requestId: ID!
  ) {
	revokeB2bConnectionRequest (
  	requestId: $requestId
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
	}
  }

```


# Get Received B2B Connection Requests

List Company connection requests that you have received and should (probably) respond to.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
query (
	$invitingCompanyId: ID
	$includedType: B2bConnectionType
	$excludedType: B2bConnectionType
	$limit: Int
  ) {
	receivedB2bConnectionRequests (
  	invitingCompanyId: $invitingCompanyId
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
	}
  }

```


# Respond to B2B Connection Requests

Provides functionality to respond to a Company connection request.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
mutation (
	$requestId: ID!
	$response: ConnectionRequestResponse!
  ) {
	respondB2bConnectionRequest (
  	requestId: $requestId
  	response: $response
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
	}
  }

```


# B2C Features


# List B2C (People) Connections

Returns list of B2C (People) connections with information about the connection, the Person/User and the company.

```
query (
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	b2cConnections (
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	type
  	insertedAt
  	updatedAt
  	startedAt
  	company {
    	id
  	}
  	connectedUser {
    	id
      }
    }
  }

```


# List Pending People Connection Requests

Returns a list of B2C connection requests that have not been responded to, with the proposed relationship type (e.g. owner, admin, customer, partner….)

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
query (
	$invitedUserId: ID
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	pendingB2cConnectionRequests (
  	invitedUserId: $invitedUserId
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# List Active Subscribers

Returns a list of B2C subscriptions for the company including the subscription channel, and all the relevant details.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```json
query (
	$userId: ID
	$includedTopic: B2cSubscriptionTopic
	$excludedTopic: B2cSubscriptionTopic
	$expirationDateBefore: Date
	$expirationDateAfter: Date
	$emailChannelEnabled: Boolean
	$smsChannelEnabled: Boolean
	$voiceChannelEnabled: Boolean
	$limit: Int
  ) {
	b2cSubscriptions (
  	userId: $userId
  	includedTopic: $includedTopic
  	excludedTopic: $excludedTopic
  	expirationDateBefore: $expirationDateBefore
  	expirationDateAfter: $expirationDateAfter
  	emailChannelEnabled: $emailChannelEnabled
  	smsChannelEnabled: $smsChannelEnabled
  	voiceChannelEnabled: $voiceChannelEnabled
  	limit: $limit
	) {
  	id
  	subscriptionTopics
  	shareInformationWithTheCompany
  	stopAllCommunications
  	expirationDate
  	notificationStartTime
  	notificationEndTime
  	timezone
  	insertedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	email {
    	email
  	}
  	smsTelephoneNumber {
    	number
  	}
  	voiceTelephoneNumber {
    	number
  	}
	}
  }

```


# List Pending Subscription Requests

Returns list of pending B2C subscription requests.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```json
  query (
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	pendingB2cConnectionRequests (
	) {
  	id
  	type
  	status
  	insertedAt
  	updatedAt
  	respondedAt
  	company {
    	id
  	}
  	invitedUser {
    	id
  	}
  	user {
    	id
  	}
}
  }

```


# Send Person (B2C) Connection Request

If you find people using search, they can send them a connection request.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
mutation (
	$invitedUserId: ID!
	$connectionType: B2cConnectionType!
  ) {
	createB2cConnectionRequest (
  	invitedUserId: $invitedUserId
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Invite People (as Company)

Invite a person to Connect with your company.

* Provide as much information as possible and create shallow (unclaimed) profiles
* Send the invites to those people and connection requests

```
mutation (
	$user: InviteUserInput!
	$connectionType: B2cConnectionType!
        ) {
	createB2cInvite (
  	user: $user
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
    	firstName
    	lastName
  	}
	}
  }

```


# Send Person (B2C) Subscription Request

When a user is found, a Company can send them a Subscription request.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
mutation (
	$invitedUserId: ID!
	$requestEmailSubscription: Boolean
	$requestSmsSubscription: Boolean
	$requestVoiceSubscription: Boolean
  ) {
	createB2cSubscriptionRequest (
  	invitedUserId: $invitedUserId
  	requestEmailSubscription: $requestEmailSubscription
  	requestSmsSubscription: $requestSmsSubscription
  	requestVoiceSubscription: $requestVoiceSubscription
	) {
  	id
  	status
  	email_requested
  	sms_requested
  	voice_requested
  	insertedAt
  	updatedAt
  	respondedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Remove B2C Connection

Use the below mutation to remove existing B2C connection(s).

```
mutation (
    $connectionId: ID!
  ) {
    removeB2cConnection (
      connectionId: $connectionId
    ) {
      id
      type
      insertedAt
      updatedAt
      startedAt
      company {
        id
      }
      connectedUser {
        id
      }
    }
  }
```


# Cancel Pending B2C Connection Request

Find a pending Connection request on the list and revoke it.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
mutation (
	$requestId: ID!
  ) {
	revokeB2cConnectionRequest (
  	requestId: $requestId
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Cancel Pending B2C Subscription Request

Find a pending Subscription request, and revoke it.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
mutation (
	$requestId: ID!
  ) {
	revokeB2cSubscriptionRequest (
  	requestId: $requestId
	) {
  	id
  	status
  	email_requested
  	sms_requested
  	voice_requested
  	insertedAt
  	updatedAt
  	respondedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Get Pending Connection Requests (People)

List pending requests made by People to connect to your Company.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
query (
	$userId: ID
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	pendingC2bConnectionRequests (
  	userId: $userId
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
  	respondedByUser {
    	id
  	}
	}
  }

```


# Respond to C2B Connection Request

Respond to a Connection request received from a Person.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
mutation (
	$requestId: ID!
	$response: ConnectionRequestResponse!
  ) {
	respondC2bConnectionRequest (
  	requestId: $requestId
  	response: $response
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
  	respondedByUser {
    	id
  	}
	}
  }

```


# Get Connected People

Returns list of Business to Consumer (B2C) Connections with information about the connection, the user and the company

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

```
query (
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	b2cConnections (
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	type
  	insertedAt
  	updatedAt
  	startedAt
  	company {
    	id
  	}
  	connectedUser {
    	id
  	}
	}
  }

```


# Generate SMS Opt-In QR Code

Use this mutation to generate an SMS opt-in QR code.

```
mutation (
      $telephoneNumberId: ID!
      $subscriptionTopicIds: [ID!]!
      $type: SmsOptInQrCodeType!
  ) {
    generateSmsOptInQrCode (
      telephoneNumberId: $telephoneNumberId
      subscriptionTopicIds: $subscriptionTopicIds
      type: $type
    ) {
      message
      qrCode
      telephoneNumber {
        id
      }
    }
  }
```


# Search People

Use this function to search for Users (People) within the TNID platform.

{% hint style="info" %}
The company GraphQL API is accessible at /company
{% endhint %}

* Search for users who have existing profiles
* Name field queries full name or username fields

```
query (
	$name: String
	$email: String
	$telephoneNumber: String
	$limit: Int
  ) {
	users (
  	name: $name
  	email: $email
  	telephoneNumber: $telephoneNumber
  	limit: $limit
	) {
  	id
  	firstName
  	lastName
  	middleName
  	username
	}
  }

```


# List Opt-Out Requests

Returns a list of Opt-out requests with information about the request, the user and the company.

```

  query (
	$type: OptOutRequestType
	$status: OptOutRequestStatus
	$source: String
	$destination: String
	$externalId: String
	$timestampBefore: NaiveDateTime
	$timestampAfter: NaiveDateTime
	$limit: Int
  ) {
	optOutRequests (
  	type: $type
  	status: $status
  	source: $source
  	destination: $destination
  	externalId: $externalId
  	timestampBefore: $timestampBefore
  	timestampAfter: $timestampAfter
  	limit: $limit
	) {
  	id
  	source
  	destination
  	externalId
  	messageBody
  	type
  	status
  	createdAt
  	updatedAt
  	timestamp
  	metadata
  	company {
    	id
    	legalName
    	brandName
    	profileName
    	taxId
    	yearFounded
    	aboutUs
    	metadata
    	verified
    	logoUrl
    	verticalType {
      	id
      	displayName
      	description
    	}
    	organizationType {
      	id
      	displayName
    	}
    	addresses {
      	city
      	country
      	state
      	street
      	types
      	zipCode
    	}
    	emails {
      	email
    	}
    	telephoneNumbers {
      	number
    	}
    	socialNetworks {
      	type
      	url
    	}
    	webpages {
      	type
      	url
    	}
    	specialties {
      	description
      	title
    	}
    	subscriptionTopics {
      	id
      	name
    	}
  	}
  	user {
    	id
    	username
    	firstName
    	middleName
    	lastName
    	birthdate
    	aboutMe
    	timezone
    	metadata
    	addresses {
      	city
      	country
      	state
      	street
      	types
      	zipCode
    	}
    	emails {
      	email
    	}
    	telephoneNumbers {
      	number
    	}
    	socialNetworks {
      	type
      	url
    	}
    	webpages {
      	type
      	url
    	}
    	interests {
      	description
      	title
    	}
  	}
	}
  }

```


# Create Opt-out Request

Creates and then returns an opt-out request.

```
mutation (
    $source: String!
    $destination: String!
    $externalId: String
    $messageBody: String
    $type: OptOutRequestType!
    $timestamp: NaiveDateTime!
    $metadata: JSON
  ) {
    createOptOutRequest (
      source: $source
      destination: $destination
      externalId: $externalId
      messageBody: $messageBody
      type: $type
      timestamp: $timestamp
      metadata: $metadata
    ) {
      id
      source
      destination
      externalId
      messageBody
      type
      status
      createdAt
      updatedAt
      timestamp
      metadata
      company {
        id
      }
    }
  }

```


# Upsert B2C Subscription

Create or update a B2C subscription.

```
mutation (
    $companyId: ID!
    $type: B2cSubscriptionType!
    $emailId: ID
    $telephoneNumberId: ID
    $subscriptionTopicIds: [ID!]!
    $expirationDate: Date
    $notificationStartTime: Time
    $notificationEndTime: Time
  ) {
    upsertB2cSubscription (
      companyId: $companyId
      type: $type
      emailId: $emailId
      telephoneNumberId: $telephoneNumberId
      subscriptionTopicIds: $subscriptionTopicIds
      expirationDate: $expirationDate
      notificationStartTime: $notificationStartTime
      notificationEndTime: $notificationEndTime
      ) {
        ... on B2cEmailSubscription {
          id
          insertedAt
          updatedAt
          type
          subscriptionTopics
          expirationDate
          notificationStartTime
          notificationEndTime
          email
          company {
            id
          }
          user {
            id
          }
        }
        ... on B2cSmsSubscription {
          id
          insertedAt
          updatedAt
          type
          subscriptionTopics
          expirationDate
          notificationStartTime
          notificationEndTime
          telephoneNumber
          company {
            id
          }
          user {
            id
          }
        }
        ... on B2cVoiceSubscription {
          id
          insertedAt
          updatedAt
          type
          subscriptionTopics
          expirationDate
          notificationStartTime
          notificationEndTime
          telephoneNumber
          company {
            id
          }
          user {
            id
          }
        }

```


# Delete B2C Subscription

```
mutation (
    $subscriptionId: ID!
  ) {
    removeB2cSubscription (
      subscriptionId: $subscriptionId
    ) {
      ... on B2cEmailSubscription {
        id
        insertedAt
        updatedAt
        type
        subscriptionTopics
        expirationDate
        notificationStartTime
        notificationEndTime
        email
        company {
          id
        }
        user {
          id
        }
      }
      ... on B2cSmsSubscription {
        id
        insertedAt
        updatedAt
        type
        subscriptionTopics
        expirationDate
        notificationStartTime
        notificationEndTime
        telephoneNumber
        company {
          id
        }
        user {
          id
        }
      }
      ... on B2cVoiceSubscription {
        id
        insertedAt
        updatedAt
        type
        subscriptionTopics
        expirationDate
        notificationStartTime
        notificationEndTime
        telephoneNumber
        company {
          id
        }
        user {
          id
        }
      }
    }
  }

```


# Update User profile

Use this feature to update User profile fields.

{% hint style="info" %}
The User GraphQL API is accessible at /user
{% endhint %}

```
 mutation (
	$username: String
	$firstName: String
	$lastName: String
	$middleName: String
	$birthdate: Date
	$aboutMe: String
	$metadata: Json
  ) {
	updateUser (
  	username: $username
  	firstName: $firstName
  	lastName: $lastName
  	middleName: $middleName
  	birthdate: $birthdate
  	aboutMe: $aboutMe
  	metadata: $metadata
	) {
  	id
  	username
  	firstName
  	lastName
  	middleName
  	birthdate
  	aboutMe
  	metadata
	}
  }

```

## Example Code

{% tabs %}
{% tab title="Python" %}

```
from datetime import datetime

import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def user_update_profile(bearer_token, username = None, first_name = None, last_name = None, middle_name = None, birthdate = None, about_me = None, metadata = None):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/user",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
            """
             mutation (
                $username: String
                $firstName: String
                $lastName: String
                $middleName: String
                $birthdate: Date
                $aboutMe: String
                $metadata: Json
              ) {
                updateUser (
                username: $username
                firstName: $firstName
                lastName: $lastName
                middleName: $middleName
                birthdate: $birthdate
                aboutMe: $aboutMe
                metadata: $metadata
                ) {
                id
                username
                firstName
                lastName
                middleName
                birthdate
                aboutMe
                metadata
                }
              }
            """
    )

    params = { "username": username,
               "firstName": first_name,
               "lastName": last_name,
               "middleName": middle_name,
               "birthdate": birthdate,
               "aboutMe": about_me,
               "metadata": metadata }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_user_token"
user_update_profile(token, "username", "John", "Smith")
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# Search User (People)

Search for users who have existing profiles. Name field queries full name or username fields.

```
query (
	$name: String
	$email: String
	$telephoneNumber: String
	$limit: Int
  ) {
	users (
  	name: $name
  	email: $email
  	telephoneNumber: $telephoneNumber
  	limit: $limit
	) {
  	id
  	username
  	firstName
  	middleName
  	lastName
  	birthdate
  	aboutMe
  	timezone
  	metadata
  	addresses {
    	city
    	country
    	state
    	street
    	types
    	zipCode
  	}
  	emails {
    	email
  	}
  	telephoneNumbers {
    	number
  	}
  	socialNetworks {
    	type
    	url
  	}
  	webpages {
    	type
    	url
  	}
  	interests {
    	description
    	title
  	}
	}
  }

```


# Invite User (People)

Provide as much information as possible and create shallow profiles. Send the invites to those people and connection requests.

```
mutation (
	$user: InviteUserInput!
	$connectionType: C2cConnectionType!
  ) {
	createC2cInvite (
  	user: $user
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedUser {
    	id
    	username
  	}
	}
  }

```


# Connections


# Send C2B Connection Request

If they find companies using search they can send them a connection request.

```
mutation (
	$invitedCompanyId: ID!
	$connectionType: B2cConnectionType!
  ) {
	CreateC2bConnectionRequest (
  	invitedCompanyId: $invitedCompanyId
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
  	respondedByUser {
    	id
  	}
	}
  }

```


# List B2C connections

```
query (
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	b2cConnections (
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	type
  	insertedAt
  	updatedAt
  	startedAt
  	company {
    	id
  	}
  	connectedUser {
    	id
  	}
	}
  }

```


# List received pending B2C Connection Requests

List received pending requests that the user needs to respond to.

```
query (
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	receivedB2cConnectionRequests (
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	company {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Respond to received B2C Connection Request

Accept or reject a received B2C connection request.

```
mutation (
	$requestId: ID!
	$response: ConnectionRequestResponse!
  ) {
	respondB2cConnectionRequest (
  	requestId: $requestId
  	response: $response
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	company {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Revoke sent C2B Connection Request

```
mutation (
	$requestId: ID!
  ) {
	revokeC2bConnectionRequest (
  	requestId: $requestId
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	invitedCompany {
    	id
  	}
  	user {
    	id
  	}
  	respondedByUser {
    	id
  	}
	}
  }

```


# List sent pending C2B Connection Requests

List sent pending requests that the user sent.

```
query (
	$includedType: B2cConnectionType
	$excludedType: B2cConnectionType
	$limit: Int
  ) {
	pendingC2bConnectionRequests (
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedCompany {
    	id
  	}
  	respondedByUser {
    	id
  	}
	}
  }

```


# Spam Reporting Features


# Create Spam Report

Use this endpoint to create a spam report.

{% hint style="info" %}
The User GraphQL API is accessible at /user
{% endhint %}

```json
  mutation (
	$fromNumber: String!
	$toNumber: String!
	$channelType: SpamReportChannelType!
	$timestamp: NaiveDateTime!
	$issueType: SpamReportIssueType
	$userNote: String
	$messageContent: String
	$metadata: Json
  ) {
	createSpamReport (
  	fromNumber: $fromNumber
  	toNumber: $toNumber
  	channelType: $channelType
  	timestamp: $timestamp
  	issueType: $issueType
  	userNote: $userNote
  	messageContent: $messageContent
  	metadata: $metadata
	) {
  	id
  	fromNumber
  	toNumber
  	userNote
  	messageContent
  	channelType
  	issueType
  	status
  	createdAt
  	updatedAt
  	timestamp
  	metadata
  	user {
    	id
  	}
	}
  }

```

## Example Code

{% tabs %}
{% tab title="Python" %}

```
from datetime import datetime

import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def user_create_spam_report(bearer_token, from_number = None, to_number = None, channel_type = None, timestamp = None, issue_type = None, user_note = None, message_content = None, metadata = None):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/user",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
            """
              mutation (
                $fromNumber: String!
                $toNumber: String!
                $channelType: SpamReportChannelType!
                $timestamp: NaiveDateTime!
                $issueType: SpamReportIssueType
                $userNote: String
                $messageContent: String
                $metadata: Json
              ) {
                createSpamReport (
                fromNumber: $fromNumber
                toNumber: $toNumber
                channelType: $channelType
                timestamp: $timestamp
                issueType: $issueType
                userNote: $userNote
                messageContent: $messageContent
                metadata: $metadata
                ) {
                id
                fromNumber
                toNumber
                userNote
                messageContent
                channelType
                issueType
                status
                createdAt
                updatedAt
                timestamp
                metadata
                user {
                    id
                }
                }
              }
            """
    )

    params = { "fromNumber": from_number,
               "toNumber": to_number,
               "channelType": channel_type,
               "timestamp": timestamp,
               "issueType": issue_type,
               "userNote": user_note,
               "messageContent": message_content,
               "metadata": metadata }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_user_token"
user_create_spam_report(token,
                        "15555555555",
                        "16666666666",
                        "MMS",
                        "2023-10-31 11:30:00",
                        "SPAM",
                        "Note about the report",
                        "Original message content",
                        "{ \"customField\": \"custom value\" }" )
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# List Spam Reports

Used to list Spam Reports with optional filters.

{% hint style="info" %}
The User GraphQL API is accessible at /user
{% endhint %}

```
query (
	$channelType: SpamReportChannelType
	$issueType: SpamReportIssueType
	$includedStatus: SpamReportStatus
	$excludedStatus: SpamReportStatus
	$limit: Int
  ) {
	spamReports (
  	channelType: $channelType
  	issueType: $issueType
  	includedStatus: $includedStatus
  	excludedStatus: $excludedStatus
  	limit: $limit
	) {
  	id
  	fromNumber
  	toNumber
  	userNote
  	messageContent
  	channelType
  	issueType
  	status
  	createdAt
  	updatedAt
  	timestamp
  	metadata
  	user {
    	id
  	}
	}
  }

```

## Example Code

{% tabs %}
{% tab title="Python" %}

```
from datetime import datetime

import aiohttp
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def user_list_spam_reports(bearer_token, channel_type = None, issue_type = None, included_status = None, excluded_status = None, limit_count = 10):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/user",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    query = gql(
            """
                query (
                    $channelType: SpamReportChannelType
                    $issueType: SpamReportIssueType
                    $includedStatus: SpamReportStatus
                    $excludedStatus: SpamReportStatus
                    $limit: Int
                  ) {
                    spamReports (
                    channelType: $channelType
                    issueType: $issueType
                    includedStatus: $includedStatus
                    excludedStatus: $excludedStatus
                    limit: $limit
                    ) {
                    id
                    fromNumber
                    toNumber
                    userNote
                    messageContent
                    channelType
                    issueType
                    status
                    createdAt
                    updatedAt
                    timestamp
                    metadata
                    user {
                        id
                    }
                    }
                  }
            """
    )

    params = { "channelType": channel_type,
               "issueType": issue_type,
               "includedStatus": included_status,
               "excludedStatus": excluded_status,
               "limit": limit_count }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)
        print(f"Response OK: {response}")
        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_user_token"
user_list_spam_reports(token, "MMS")
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}


# Company Features


# Search Companies

This will return a list of companies matching the query and in case queried props are visible to the querier, it will be possible to query by:

* ID
* Legal name (with name field)
* Brand name (with name field)
* Profile name (with name field)
* TaxID
* Telephone number
* Email
* Webpage (social media or other)

Each result will return a list of companies. It is possible to pass a combination of queryable props.

```
query (
    $id: ID
    $name: String
    $taxId: String
    $email: String
    $telephoneNumber: String
    $webpage: String
    $limit: Int
    $metadata: JSON
  ) {
    companies (
      id: $id
      name: $name
      taxId: $taxId
      email: $email
      telephoneNumber: $telephoneNumber
      webpage: $webpage
      limit: $limit
      metadata: $metadata
    ) {
      id
      legalName
      brandName
      profileName
      taxId
      yearFounded
      aboutUs
      metadata
      verified
      logoUrl
      verticalType {
        id
        displayName
        description
      }
      organizationType {
        id
        displayName
      }
      addresses {
        city
        country
        state
        street
        types
        zipCode
      }
      emails {
        email
      }
      telephoneNumbers {
        number
      }
      socialNetworks {
        type
        url
      }
      webpages {
        type
        url
      }
      specialties {
        description
        title
      }
      subscriptionTopics {
        id
        name
      }
      subscriptionSettings {
        enable_email
        enable_sms
        enable_voice
      }
    }
  }

```


# Create company profile

```
mutation (
    $legalName: String!
    $brandName: String
    $profileName: String!
    $taxId: String
    $yearFounded: Int
    $aboutUs: String
    $metadata: JSON
    $emails: [CompanyEmailInput!]
    $telephoneNumbers: [CompanyTelephoneNumberInput!]
    $addresses: [CompanyAddressInput!]
    $webpages: [WebpageInput!]
    $socialNetworks: [SocialMediaInput!]
    $trustedDomains: [TrustedDomainInput!]
    $subscriptionTopics: [B2cSubscriptionTopicInput!]
    $subscriptionSettings: CompanySubscriptionSettingsInput
    $verticalTypeId: ID
    $organizationTypeId: ID
    $companySpecialties: [ID]
    $legalNameVisibility: [CompanyVisibilityType!]
    $brandNameVisibility: [CompanyVisibilityType!]
    $taxIdVisibility: [CompanyVisibilityType!]
    $aboutUsVisibility: [CompanyVisibilityType!]
    $yearFoundedVisibility: [CompanyVisibilityType!]
    $verticalTypeVisibility: [CompanyVisibilityType!]
    $organizationTypeVisibility: [CompanyVisibilityType!]
    $specialtiesVisibility: [CompanyVisibilityType!]
    $b2cVisibility: [CompanyVisibilityType!]
    $metadataVisibility: [CompanyVisibilityType!]
    $provisionCompanyClientSecret: Boolean
    $connectionType: AdminB2cConnectionType
  ) {
    createCompany (
      legalName: $legalName
      brandName: $brandName
      profileName: $profileName
      taxId: $taxId
      yearFounded: $yearFounded
      aboutUs: $aboutUs
      metadata: $metadata
      emails: $emails
      telephoneNumbers: $telephoneNumbers
      addresses: $addresses
      webpages: $webpages
      socialNetworks: $socialNetworks
      trustedDomains: $trustedDomains
      subscriptionTopics: $subscriptionTopics
      subscriptionSettings: $subscriptionSettings
      verticalTypeId: $verticalTypeId
      organizationTypeId: $organizationTypeId
      companySpecialties: $companySpecialties
      legalNameVisibility: $legalNameVisibility
      brandNameVisibility: $brandNameVisibility
      taxIdVisibility: $taxIdVisibility
      aboutUsVisibility: $aboutUsVisibility
      yearFoundedVisibility: $yearFoundedVisibility
      verticalTypeVisibility: $verticalTypeVisibility
      organizationTypeVisibility: $organizationTypeVisibility
      specialtiesVisibility: $specialtiesVisibility
      b2cVisibility: $b2cVisibility
      metadataVisibility: $metadataVisibility
      provisionCompanyClientSecret: $provisionCompanyClientSecret
      connectionType: $connectionType
    ) {
      id
      clientSecret {
      clientId
      clientSecret
      description
      }
    }
  }

```


# Create Company Client Secret

Create a company client secret using the below mutation.

```
mutation (
    $companyId: ID!
    $description: String
  ) {
    createCompanyClientSecret (
      companyId: $companyId
      description: $description
    ) {
      clientId
      clientSecret
      description
    }
  }

```


# List Pending C2C Connection Requests

Returns a list of pending connection requests this user sent to other users.

```
query (
	$invitedUserId: ID
	$includedType: C2cConnectionType
	$excludedType: C2cConnectionType
	$limit: Int
  ) {
	pendingC2cConnectionRequests (
  	invitedUserId: $invitedUserId
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Remove C2C Connection

Use the below mutation to remove an existing C2C connection.

```
mutation (
    $connectionId: ID!
  ) {
    removeC2cConnection (
      connectionId: $connectionId
    ) {
      id
      type
      insertedAt
      updatedAt
      startedAt
      user {
        id
      }
      connectedUser {
        id
      }
    }
  }

```


# Revoke sent C2C Connection Request

Revoke a C2C connection request you sent.

```
mutation (
	$requestId: ID!
  ) {
	revokeC2cConnectionRequest (
  	requestId: $requestId
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	invitedUser {
    	id
  	}
  	user {
    	id
  	}


	}
  }

```


# List Received C2C Connection Requests

The user can list pending connection requests they need to respond.

```
query (
	$invitingUserId: ID
	$includedType: C2cConnectionType
	$excludedType: C2cConnectionType
	$limit: Int
  ) {
	receivedC2cConnectionRequests (
  	invitingUserId: $invitingUserId
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Send C2C Connection Request

Find people using search, and then send them a connection request

```
mutation (
	$invitedUserId: ID!
	$connectionType: C2cConnectionType!
  ) {
	createC2cConnectionRequest (
  	invitedUserId: $invitedUserId
  	connectionType: $connectionType
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Respond C2C Connection Request

Respond to the connection request received from people.

```
 mutation (
	$requestId: ID!
	$response: ConnectionRequestResponse!
  ) {
	respondC2cConnectionRequest (
  	requestId: $requestId
  	response: $response
	) {
  	id
  	status
  	type
  	insertedAt
  	respondedAt
  	updatedAt
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# List C2C Connections

Returns list of C2C connections with information about the connection, and the users.

```
query (
	$includedType: C2cConnectionType
	$excludedType: C2cConnectionType
	$limit: Int
  ) {
	c2cConnections (
  	includedType: $includedType
  	excludedType: $excludedType
  	limit: $limit
	) {
  	id
  	type
  	insertedAt
  	updatedAt
  	startedAt
  	user {
    	id
  	}
  	connectedUser {
    	id
  	}
	}
  }

```


# Remove B2C Subscription

```
mutation (
    $subscriptionId: ID!
  ) {
    removeB2cSubscription (
      subscriptionId: $subscriptionId
    ) {
      ... on B2cEmailSubscription {
        id
        insertedAt
        updatedAt
        type
        subscriptionTopics
        expirationDate
        notificationStartTime
        notificationEndTime
        email
        company {
          id
        }
        user {
          id
        }
      }
      ... on B2cSmsSubscription {
        id
        insertedAt
        updatedAt
        type
        subscriptionTopics
        expirationDate
        notificationStartTime
        notificationEndTime
        telephoneNumber
        company {
          id
        }
        user {
          id
        }
      }
      ... on B2cVoiceSubscription {
        id
        insertedAt
        updatedAt
        type
        subscriptionTopics
        expirationDate
        notificationStartTime
        notificationEndTime
        telephoneNumber
        company {
          id
        }
        user {
          id
        }
      }
    }
  }

```


# Respond to B2C Subscription Request

```
mutation (
    $requestId: ID!
    $response: SubscriptionRequestResponse!
  ) {
    respondB2cSubscriptionRequest (
      requestId: $requestId
      response: $response
    ) {
      id
      status
      type
      insertedAt
      respondedAt
      updatedAt
      user {
        id
      }
      company {
        id
      }
      invitedUser {
        id
      }
    }
  }

```


# Group Features


# Search Groups

Search for groups. Each result will return a list of groups.

```
   query (
	$name: String
	$limit: Int
  ) {
	groups (
  	name: $name
  	limit: $limit
	) {
  	id
  	name
  	metadata
  	logo_url
  	visibility
	}
  }

```


# List User's Groups

List the groups the user is a member of with their role.

```
  query (
	$limit: Int
  ) {
	userGroups (
  	limit: $limit
	) {
  	role
  	group {
  	id
  	name
  	metadata
  	logo_url
  	visibility
  	}
	}
  }

```


# Create Group

```
mutation (
	$name: String!
	$metadata: JSON
	$visibility: [GroupVisibilityType!]
  ) {
	createGroup (
  	name: $name
  	metadata: $metadata
  	visibility: $visibility
	) {
  	id
  	}
    }

```


# Update group

```
   mutation (
	$groupId: ID!
	$name: String
	$metadata: JSON
	$visibility: [GroupVisibilityType!]
  ) {
	updateGroup (
  	groupId: $groupId
  	name: $name
  	metadata: $metadata
  	visibility: $visibility
	) {
  	id
  	name
  	metadata
  	visibility
  	}
}

```


# Invite User to Group

Send an invite to a user to a group.

```
 mutation (
	$groupId: ID!
	$invitedUserId: ID!
	$role: GroupRoleType!
  ) {
	createGroupUserMemberInvite (
  	groupId: $groupId
  	invitedUserId: $invitedUserId
  	role: $role
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Respond to Group invite

Respond to a group invite you received.

```
 mutation (
	$inviteId: ID!
	$response: GroupInviteResponse!
  ) {
	respondGroupUserMemberInvite(
  	inviteId: $inviteId
  	response: $response
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# List pending Group invites (Sent)

```
query (
	$groupId: ID
	$invitedUserId: ID
	$limit: Int
  ) {
	pendingGroupUserMemberInvites (
  	groupId: $groupId
  	invitedUserId: $invitedUserId
  	limit: $limit
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# List pending Group invites (Received)

```
   query (
	$invitingUserId: ID
	$limit: Int
  ) {
	receivedGroupUserMemberInvites (
  	invitingUserId: $invitingUserId
  	limit: $limit
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Revoke Pending Group User Member Invite

```
mutation (
	$inviteId: ID!
  ) {
	revokeGroupUserMemberInvite(
  	inviteId: $inviteId
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
  	invitedUser {
    	id
  	}
	}
  }

```


# Send Group user member join request

```
mutation (
	$groupId: ID!
  ) {
	createGroupUserMemberJoinRequest (
  	groupId: $groupId
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
	}
  }

```


# List Received Pending Group user member join request

Group admins can list pending group user member join requests to a group.

```
 query (
	$groupId: ID!
	$limit: Int
  ) {
	receivedGroupUserMemberJoinRequests (
  	groupId: $groupId
  	limit: $limit
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
	}
  }

```


# List Pending Group user member join request

```
 query (
	$limit: Int
  ) {
	pendingGroupUserMemberJoinRequests (
  	limit: $limit
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
	}
  }

```


# Revoke Group user member join request

```
mutation (
	$joinRequestId: ID!
  ) {
	revokeGroupUserMemberJoinRequest(
  	joinRequestId: $joinRequestId
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
	}
  }

```


# Respond to Group user member join request

Group admin can accept or reject a pending group user member join request.

```
 mutation (
	$joinRequestId: ID!
	$response: GroupInviteResponse!
  ) {
	respondGroupUserMemberJoinRequest(
  	joinRequestId: $joinRequestId
  	response: $response
	) {
  	id
  	status
  	role
  	insertedAt
  	respondedAt
  	updatedAt
  	group {
    	id
  	}
  	user {
    	id
  	}
	}
  }

```


# Create Company (Brand)

Coming soon.


# Create Campaign

Coming soon.


