Skip to main content
Using TypeScript? Check out our GraphQL SDK for a fully typed client.
Plain auto-creates companies from customer email domains, but you can also upsert them directly via the API. This is useful when you want to set details like the company name, logo or account owner ahead of any customers being created. upsertCompany will create a new company if one with the given identifier doesn’t exist, or update it in place if it does. The mutation returns a result field of either CREATED or UPDATED so you can tell which happened. A company is identified by either its Plain companyId or its companyDomainName. When upserting by domain, you can pass either a bare domain (e.g. plain.com) or a full URL (e.g. https://www.plain.com) and we’ll extract the domain for you. This operation requires the following permissions:
  • company:create
  • company:edit
Mutation
mutation upsertCompany($input: UpsertCompanyInput!) {
  upsertCompany(input: $input) {
    result
    company {
      id
      name
      domainName
    }
    error {
      message
      type
      code
      fields {
        field
        message
        type
      }
    }
  }
}
Variables
{
  "input": {
    "identifier": {
      "companyDomainName": "plain.com"
    },
    "name": "Plain",
    "domainName": "plain.com"
  }
}