menu button

Optional calls

Create API Organization

Create API Organization

Use the createApiOrganization mutation to programmatically create a new API organization. This returns the organization details along with a plainKey — the API key for that organization. Store the plainKey securely, as it will not be retrievable again.


Input Parameters

  • name (String!) — the name of the organization to create.

GraphQL Mutation

mutation CreateApiOrganization($name: String!) {
  createApiOrganization(name: $name) {
    organization {
      id
      name
    }
    plainKey
  }
}

Mutation Variables

{
  "name": "My Organization Name"
}

Example JavaScript Implementation

import axios from "axios";

const CREATE_API_ORGANIZATION = `
  mutation CreateApiOrganization($name: String!) {
    createApiOrganization(name: $name) {
      organization {
        id
        name
      }
      plainKey
    }
  }
`;

const createApiOrganization = async (name) => {
  const res = await axios({
    method: "POST",
    url: "https://api-v2.speechmind.com/external/v2/graphql",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": process.env.SPEECHMIND_API_KEY,
    },
    data: JSON.stringify({
      query: CREATE_API_ORGANIZATION,
      variables: { name },
    }),
  });

  const { organization, plainKey } = res.data.data.createApiOrganization;
  console.log("Created Organization:", organization);
  console.log("API Key (store securely):", plainKey);

  return { organization, plainKey };
};

Notes

  • The plainKey in the response is the API key for the newly created organization. It is only returned once — store it securely immediately.
  • The id and name returned under organization can be used to reference this organization in future API calls.

Have questions?

Still have questions? Talk to support.