Invite Company
On this page
Invite a company to join the TNID ecosystem with createB2bInvite: pre-fill its profile, name at least one representative, and propose a connection type.
Invite a company to join the TNID ecosystem.
The company GraphQL API is accessible at /company
- Include as much data as possible in the invitation so the invitee only has to verify and confirm (they can still change it).
- At least one representative must be included so that, after they register, they can take over management of the newly created company.
- The connection request must be confirmed/accepted by the newly created company's legal representative.
- Most properties are flagged private so the newly created company's data is not exposed.
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 variables:
{
"company": {
"legalName": "Acme Metals",
"brandName": "Acme",
"aboutUs": "Sheet metal fabrication",
"yearFounded": 1998
},
"representatives": [
{
"email": "jane.smith@acme-metals.example",
"firstName": "Jane",
"lastName": "Smith",
"telephoneNumber": "15555550100",
"sendInviteEmail": true
}
],
"connectionType": "PARTNER"
}
Example Code
Python
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 invite_company(bearer_token, company_to_invite, company_representatives, connection_type):
transport = AIOHTTPTransport(
url="https://api.staging.v2.tnid.com/company",
headers={"Authorization": f"Bearer {bearer_token}"}
)
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:
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_representatives = [{"email": "jane.smith@acme-metals.example", "firstName": "Jane", "lastName": "Smith", "sendInviteEmail": True}]
token = "your_company_token"
invite_company(token, company_to_invite, company_representatives, "PARTNER")