Optional calls
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.
Create API Organization
name(String, required) — the name of the organization to create.
Example GraphQL Mutation
mutation CreateApiOrganization($name: String!) {
createApiOrganization(name: $name) {
organization {
id
name
}
plainKey
}
}
Example Variables
{
"name": "My Organization Name"
}
JavaScript Example (Axios)
import axios from "axios";
export const CREATE_API_ORGANIZATION = `
mutation CreateApiOrganization($name: String!) {
createApiOrganization(name: $name) {
organization {
id
name
}
plainKey
}
}
`;
const createApiOrganization = async (name) => {
try {
const response = 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 } = response.data.data.createApiOrganization;
console.log("Created Organization:", organization);
console.log("API Key (store securely):", plainKey);
return { organization, plainKey };
} catch (error) {
console.error("Error creating API organization:", error);
}
};
// Example usage:
createApiOrganization("My Organization Name");
Notes
- The
plainKeyin the response is the API key for the newly created organization. It is only returned once — store it securely. - The
idandnamereturned underorganizationcan be used to reference this organization in future API calls.
Have questions?
Still have questions? Talk to support.