Webtask

Documentation

Webtask creation

Simplified webtask creation

Simplified webtask creation

Sometimes all you want to do is create a new named webtask and get to work right away. Understanding the nuances of webtask token claims is overkill in many circumstances.

This endpoint gives you an easy way to get started creating and updating named webtasks.

Creating or updating a webtask

HTTPS PUT /api/webtask/{webtask_container}/{webtask_name}
Content-Type: application/json        

The request must be authenticated by specifying the A1 webtask token as the key URL query parameter or with the Authorization HTTP request header as described above. The content type of the request must be application/json. The body of the request must contain a JSON object having the following fields:

code

Pass in the code that the webtask will run on every request. The code must export a function whose signature matches one of the webtask programming models.

url

Pass in a url from which the webtask server will fetch the code to run on every request. The url must be publicly accessible and resolve to code that exports a function whose signature matches one of the webtask programming models.

NOTE: either the code orurl field must be set, but not both.

secrets

Pass in an optional object whose keys / value pairs represent secrets that will be encrypted and embedded within the underlying token and will be available on the secrets parameter of the context object.

meta

Pass in a set of string key / value pairs in order to set metadata that describe your webtask. Later on you can retrieve the metadata for a given webtask or even filter your webtasks searching for specific metadata properties.

HTTPS PUT /api/webtask/{webtask_container}/{webtask_name}
{
 ...,
 meta: {
   name: 'auth0-logging-extension',
   version: '1.0.0',
   description: 'Real-time webtask logs'
 }
}

If a webtask with metadata already exists, and an upsert call is made without the metadata parameter, existing metadata will be deleted.

Response

Successful requests to create or update a named webtask will respond with a JSON object with the following properties:

container

The container in which the created webtask will run.

name

The name of the created webtask. This corresponds to the jtn claim in the token.

token

The webtask token representing this named webtask.

HINT: The created webtask can be run at the following url patterns:
/api/run/{webtask_container}/{webtask_name}
/api/run/{webtask_container}/{webtask_name}/{anything*}