Trigger CC via HTTP

Version Compatibility

This feature is compatible with v1.1.0 and later of CloudCode.

You can trigger a CloudCode Task via HTTP. This is referred to as a Web Task.

In this way, CloudCode can be used to create a JSON-based HTTP API.

The task will need to have the "Web Request" trigger enabled in the task's configuration.

The hostnames (with .poweredbyjourney.com suffix) for an app's web-triggered CloudCode tasks are configured by editing an app deployment in the Deployments workspace in OXIDE.

After deploying, enabled tasks are accessible on https://<your_app_deployment_hostname>.poweredbyjourney.com/<task>.

Note that domain names are globally unique, so care is required when choosing hostnames for each of your apps and app deployments. Consider using the organization name, app name, and a -testing or -staging suffix for the corresponding deployments. e.g.

  • https://acme-my-app-testing.poweredbyjourney.com/my_web_task,

  • https://acme-my-app-staging.poweredbyjourney.com/my_web_task,

  • https://acme-my-app.poweredbyjourney.com/my_web_task.

A Minimal Example

Here's a minimal example of a task that can handle GET requests:

// This MUST be defined, and either return access.unauthorized() or access.authorized().
export async function authenticate({request, access}) {
    return access.authorized();
}

export async function get({params, request, response}) {
    return {hello: 'world'};
}

Authentication Example

This is an example implementation of authentication for a POST request.

Request and Response Details

Limitations

  • Custom domains are not supported - only *.poweredbyjourney.com.

  • Custom paths are not supported.

  • Only application/json is supported for request format, and application/json, text/html or text/plain for response format. Binary data specifically is not supported.

Last updated