Auth Token

Auth tokens are created with a Portive API Key.

You can get a free API key from the Portive website.

Static Methods

createAuthToken(apiKey: string, options: object) => string

  apiKey: string,
    // WARNING: If a `number` the value will be in ms.
    // Recommending using a `string` like `1d` for 1 day.
    // `1h` for 1 hour, `1m` for 1 minute, etc.
    expiresIn: string | number
    maxFileBytes?: number
    maxFileBytesMessage?: string
    tags?: string[]
) => string

This function generates an authentication token given an apiKey and a set of configurable options. This token can be used for authenticating requests. You can get an API key by logging into https://portive.com.


  • apiKey (string): Your unique API key. This is required and is used as the primary credential to generate the authentication token.

  • options (object): A set of configuration parameters that allow you to control the properties of the generated token. The properties are:

    • expiresIn (string | number): The duration after which the token expires. The value can either be a string or a number. If a string is provided, it should be in the format used by the ms library (e.g., "2 days", "3 hours", "3h", etc.). If a number is provided, it should be in milliseconds.

    • maxFileBytes? (number): The maximum number of bytes allowed for this file upload.

    • maxFileBytesMessage (string): The error message to return if the maxFileBytes is exceeded. Can be useful to indicate to a user that they can upgrade to increase their max file size limit for example.

    • tags? (string[]): An optional array of tags to include in the token. These tags are automatically added to any uploaded files and can be used to track things like the page the upload came from or the user that uploaded. By convention, we recommend a format something like userid:12345, pageid:888, type:blog, or project:alpha.


(string): The function returns the generated authentication token as a string.