InfoThis documentation is just for PropelAuth Components, an optional library for those who want deeper design control over their UIs.Click here to view our standard documentation

Create Organization API Key Component

PropelAuth's Create Org API Key Component allow you to customize the UI around creating an org's API Keys. For more information on API Keys, check out our docs here.

Create Organization API Key


Reference APIs

These are the APIs that are used by the above component. You can use these APIs directly in your own code.

createOrgApiKey

Creates an Org API key for the provided organization.

Arguments

  • Name
    orgId *
    Type
    string
    Description
    The ID of the org to create an API key for
  • Name
    expirationOption *
    Type
    string
    Description
    Can be one of the following: 'TwoWeeks' | 'OneMonth' | 'ThreeMonths' | 'SixMonths' | 'OneYear' | 'Never'

Success Response

  • Name
    api_key_id
    Type
    string
    Description
    The ID of the API Key.
  • Name
    api_key_token
    Type
    string
    Description
    The API Key.

Response Functions

The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.

  • Name
    success
    Description
    Successful request.
  • Name
    invalidExpirationOption
    Description
    Incorrect argument provided for 'expirationOption'
  • Name
    noOrgApiKeyPermission
    Description
    User does not have permission to create an org API key.
  • Name
    unauthorized
    Description
    The user is not logged in.
  • Name
    unexpectedOrUnhandled
    Description
    An unexpected error occurred.

Request

const { createOrgApiKey } = useAuthFrontendApis()

const response = await createOrgApiKey(orgId, 'Never')
await response.handle({
    success: async () => {
        console.log('success')
    },
    invalidExpirationOption(error) {
        console.error('Invalid expiration option', error.user_facing_error)
    },
    noOrgApiKeyPermission(error) {
        console.error('Forbidden', error.user_facing_error)
    },
    unexpectedOrUnhandled(error) {
        console.error('Unexpected or unhandled error', error.user_facing_error)
    },
})

Successful Response

{
    "api_key_id": "justAnId",
    "api_key_token": "dhopw42..."
}