Cloud Functions

Live

Cloud Functions

+ Day(s) remaining in the trial

Overview

IBM Cloud Functions is a distributed compute service that executes application logic in response to requests from web or mobile apps. You can set up specific actions to occur based on HTTP-based API requests from web apps or mobile apps, and from event-based requests from services like Cloudant. Functions can run your code snippets on demand or automatically in response to events. All APIs are protected with HTTP Basic authentication. You can use the [`wskadmin` tool](https://github.com/apache/incubator-openwhisk/tree/master/tools/admin) to generate a new namespace and authentication. The Basic authentication credentials are in the `AUTH` property in your `~/.wskprops` file, delimited by a colon. You can also retrieve these credentials by using the CLI running `ibmcloud wsk property get --auth`. In the following cURL example, authentication is passed by using the `-u` flag: `curl -u USERNAME:PASSWORD https://openwhisk.ng.bluemix.net/api/v1/namespaces`. You can also include authentication part of the URL: `curl https://USERNAME:PASSWORD@openwhisk.ng.bluemix.net/api/v1/namespaces`. For the {namespace} in the URL, the underscore character (`_`) can be used to specify the user's default namespace.

Security

Keys

Pick a key to use with this API. Make sure you are logged in with your IBM id for your keys to be populated in the dropdown below. By selecting a key, it will be pre-filled for each endpoint in the Documentation section that can be used with the built-in testing. If you want to change which key to use for a particular endpoint, you can do so at the endpoint in the Documentation section.
You can manage your API keys in the <MyAPIs> section. API keys authenticate you to your subscription, so make sure to keep them secret. Do not share the X-IBM-Client-Secret portion of any API key in publicly accessible places such as GitHub, or client-side code.



Manage your keys
 

Documentation

Cloud Functions:

Actions

Create or update an action
Create or update an action, web action, or action sequence.

PUT   /namespaces/{namespace}/actions/{actionName}

			https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}
		
Keys
Path and Query parameters

actionName

URL , required

Name of the entity.

namespace

URL , required

Namespace that the entity is in.

overwrite

BOOLEAN , optional

Enter `true` to overwrite the entity if it exists. The default is `false`.

Request code
								
HttpResponse<String> response = Unirest.put("https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}?overwrite=true") .header("accept", "application/json") .header("content-type", "application/json") .body("{\"annotations\":{\"description\":\"Annotations on the entity. For a list of annotations for web actions, see the [documentation](https://console.bluemix.net/docs/openwhisk/openwhisk_annotations.html#annotations-specific-to-web-actions).\",\"items\":{\"properties\":{\"key\":\"string\",\"value\":{\"description\":\"Any JSON value\",\"type\":\"object\"}},\"type\":\"object\"},\"properties\":{\"key\":\"string\",\"value\":{\"description\":\"Any JSON value\",\"type\":\"object\"}},\"type\":\"object\"},\"exec\":{\"description\":\"Details about what the entity executes\",\"properties\":{\"binary\":true,\"code\":\"string\",\"components\":\"string\",\"image\":\"string\",\"init\":\"string\",\"kind\":\"\\\"nodejs:8\\\"\"},\"type\":\"object\"},\"limits\":{\"description\":\"Limits on this entity\",\"properties\":{\"logs\":0,\"memory\":0,\"timeout\":0},\"type\":\"object\"},\"parameters\":{\"description\":\"Parameter bindings included in the context passed to the entity\",\"items\":{\"properties\":{\"key\":\"string\",\"value\":{\"description\":\"Any JSON value\",\"type\":\"object\"}},\"type\":\"object\"},\"properties\":{\"key\":\"string\",\"value\":{\"description\":\"Any JSON value\",\"type\":\"object\"}},\"type\":\"object\"},\"publish\":true,\"version\":\"string\"}") .asString();
Request model

annotations

OBJECT , optional

Annotations on the entity. For a list of annotations for web actions, see the [documentation](https://console.bluemix.net/docs/openwhisk/openwhisk_annotations.html#annotations-specific-to-web-actions).

exec

OBJECT , optional

Details about what the entity executes

limits

OBJECT , optional

Limits on this entity

parameters

OBJECT , optional

Parameter bindings included in the context passed to the entity

publish

BOOLEAN , optional

Whether to publish the entity or not

version

STRING , optional

Semantic version of the entity

key

STRING , optional

The key value

value

OBJECT , optional

Any JSON value

binary

BOOLEAN , optional

code

STRING , optional

Javascript or Swift code to execute when kind is `nodejs` or `swift`

components

STRING , optional

The actions in the sequence when kind is `sequence`. The actions are listed in order.

image

STRING , optional

Container image name when kind is `blackbox`

init

STRING , optional

Optional zipfile reference when kind is `nodejs`

kind

STRING , optional

The type of entity

logs

INTEGER , optional

memory

INTEGER , optional

timeout

INTEGER , optional

key

STRING , optional

The key value

value

OBJECT , optional

Any JSON value

Request example
{
  "annotations": {
    "key": string,
    "value": object
  },
  "exec": {
    "binary": boolean,
    "code": string,
    "components": string,
    "image": string,
    "init": string,
    "kind": ""nodejs:8""
  },
  "limits": {
    "logs": integer,
    "memory": integer,
    "timeout": integer
  },
  "parameters": {
    "key": string,
    "value": object
  },
  "publish": boolean,
  "version": string
}
Response model

200

OK

Body

activationId

STRING , optional

The activation record ID for the action invocation.

400

Bad Request

Body

code

INTEGER , optional

error

STRING , optional

401

Unauthorized

Body

code

INTEGER , optional

error

STRING , optional

409

Conflict

Body

code

INTEGER , optional

error

STRING , optional

500

Internal Server Error

Body

code

INTEGER , optional

error

STRING , optional

Response example

200

OK

								{
  "activationId" : string
}
							

400

Bad Request

								{
  "code" : integer,
  "error" : string
}
							

401

Unauthorized

								{
  "code" : integer,
  "error" : string
}
							

409

Conflict

								{
  "code" : integer,
  "error" : string
}
							

500

Internal Server Error

								{
  "code" : integer,
  "error" : string
}
							
Delete an action
Delete an action, web action, or action sequence.

DELETE   /namespaces/{namespace}/actions/{actionName}

			https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}
		
Keys
Path and Query parameters

actionName

URL , required

Name of the entity.

namespace

URL , required

Namespace that the entity is in.

Request code
								
HttpResponse<String> response = Unirest.delete("https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}") .header("accept", "application/json") .header("content-type", "application/json") .asString();
Response model

200

OK

401

Unauthorized

Body

code

INTEGER , optional

error

STRING , optional

404

Not Found

Body

code

INTEGER , optional

error

STRING , optional

500

Internal Server Error

Body

code

INTEGER , optional

error

STRING , optional

Response example

200

OK

401

Unauthorized

								{
  "code" : integer,
  "error" : string
}
							

404

Not Found

								{
  "code" : integer,
  "error" : string
}
							

500

Internal Server Error

								{
  "code" : integer,
  "error" : string
}
							
Get action information
Get information on a specified action, web action, or action sequence.

GET   /namespaces/{namespace}/actions/{actionName}

			https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}
		
Keys
Path and Query parameters

actionName

URL , required

The name of the entity you want to get information for. To list all actions in a namespace, use the `/namespaces/{namespace}/actions` call.

namespace

URL , required

Namespace that the entity is in.

Request code
								
HttpResponse<String> response = Unirest.get("https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}") .header("accept", "application/json") .asString();
Response model

200

Returned action

Body

annotations

ARRAY , optional

Annotations on this entity

exec [ActionExec]

OBJECT , optional

Details about what the entity executes

limits [ActionLimits]

OBJECT , optional

Limits on this entity

name

STRING , optional

Name of the entity

namespace

STRING , optional

Namespace that this entity is in

parameters

STRING , optional

Parameter bindings included in the context passed to the entity

publish

BOOLEAN , optional

Whether to publish the entity or not

updated

INTEGER , optional

Last-updated Unix epoch timestamp

version

STRING , optional

Semantic version of the entity

binary

BOOLEAN , optional

code

STRING , optional

Javascript or Swift code to execute when kind is `nodejs` or `swift`

components

STRING , optional

The actions in the sequence when kind is `sequence`. The actions are listed in order.

image

STRING , optional

Container image name when kind is `blackbox`

init

STRING , optional

Optional zipfile reference when kind is `nodejs`

kind

STRING , optional

The type of entity

logs

INTEGER , optional

memory

INTEGER , optional

timeout

INTEGER , optional

401

Unauthorized

Body

code

STRING , optional

error

STRING , optional

Unauthorized

404

Not Found

Body

code

STRING , optional

error

STRING , optional

The requested resource could not be found.

500

Internal Server Error

Body

code

STRING , optional

error

STRING , optional

Internal Server Error. IBM Cloud Functions is currently unavailable. Your request could not be processed. Please wait a few minutes and try again.

Response example

200

Returned action

								{
  "annotations" : [string],
  "exec" : {
    "binary" : boolean,
    "code" : string,
    "components" : string,
    "image" : string,
    "init" : string,
    "kind" : ""nodejs:8""
  },
  "limits" : {
    "logs" : integer,
    "memory" : integer,
    "timeout" : integer
  },
  "name" : string,
  "namespace" : string,
  "parameters" : string,
  "publish" : boolean,
  "updated" : integer,
  "version" : string
}
							

401

Unauthorized

								{
  "code" : string,
  "error" : "Unauthorized"
}
							

404

Not Found

								{
  "code" : string,
  "error" : "The requested resource could not be found."
}
							

500

Internal Server Error

								{
  "code" : string,
  "error" : "Internal Server Error. IBM Cloud Functions is currently unavailable. Your request could not be processed. Please wait a few minutes and try again."
}
							
Get all actions
Get all actions, web actions, and action sequences in a namespace.

GET   /namespaces/{namespace}/actions

			https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions
		
Keys
Path and Query parameters

limit

INTEGER , optional

Number of actions to include in the result.

namespace

URL , required

Namespace that the action is in.

skip

INTEGER , optional

Number of actions to skip in the result.

Request code
								
HttpResponse<String> response = Unirest.get("https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions?limit=0&skip=0") .header("accept", "application/json") .asString();
Response model

200

OK

Body

annotations

ARRAY , optional

Annotations on this entity

exec [ActionExec]

OBJECT , optional

Details about what the entity executes

limits [ActionLimits]

OBJECT , optional

Limits on this entity

name

STRING , optional

Name of the entity

namespace

STRING , optional

Namespace that this entity is in

parameters

STRING , optional

Parameter bindings included in the context passed to the entity

publish

BOOLEAN , optional

Whether to publish the entity or not

updated

INTEGER , optional

Last-updated Unix epoch timestamp

version

STRING , optional

Semantic version of the entity

binary

BOOLEAN , optional

code

STRING , optional

Javascript or Swift code to execute when kind is `nodejs` or `swift`

components

STRING , optional

The actions in the sequence when kind is `sequence`. The actions are listed in order.

image

STRING , optional

Container image name when kind is `blackbox`

init

STRING , optional

Optional zipfile reference when kind is `nodejs`

kind

STRING , optional

The type of entity

logs

INTEGER , optional

memory

INTEGER , optional

timeout

INTEGER , optional

401

Unauthorized

Body

code

STRING , optional

error

STRING , optional

Unauthorized

403

Forbidden

Body

code

STRING , optional

error

STRING , optional

Forbidden

500

Internal Server Error

Body

code

STRING , optional

error

STRING , optional

Internal Server Error. IBM Cloud Functions is currently unavailable. Your request could not be processed. Please wait a few minutes and try again.

Response example

200

OK

								[{
  "annotations" : [string],
  "exec" : {
    "binary" : boolean,
    "code" : string,
    "components" : string,
    "image" : string,
    "init" : string,
    "kind" : ""nodejs:8""
  },
  "limits" : {
    "logs" : integer,
    "memory" : integer,
    "timeout" : integer
  },
  "name" : string,
  "namespace" : string,
  "parameters" : string,
  "publish" : boolean,
  "updated" : integer,
  "version" : string
}]
							

401

Unauthorized

								{
  "code" : string,
  "error" : "Unauthorized"
}
							

403

Forbidden

								{
  "code" : string,
  "error" : "The supplied authentication is not authorized to access '{namespace}'."
}
							

500

Internal Server Error

								{
  "code" : string,
  "error" : "Internal Server Error. IBM Cloud Functions is currently unavailable. Your request could not be processed. Please wait a few minutes and try again."
}
							
Invoke an action
Invoke an action, web action, or action sequence. Each invocation results in an activation record.

POST   /namespaces/{namespace}/actions/{actionName}

			https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}
		
Keys
Path and Query parameters

actionName

URL , required

Name of the entity to invoke.

blocking

BOOLEAN , optional

Blocking or non-blocking invocation. Default is non-blocking.

namespace

URL , required

Namespace that the entity is in.

Request code
								
HttpResponse<String> response = Unirest.post("https://openwhisk.ng.bluemix.net/api/v1/namespaces/{namespace}/actions/{actionName}?blocking=true") .header("accept", "application/json") .header("content-type", "application/json") .asString();
Request model

object , optional

Request example
{
  "": object
}
Response model

200

Activation

Body

activationId

STRING , optional

ID of this activation

annotations

ARRAY , optional

For a list of activation annotations, see the [documentation](https://console.bluemix.net/docs/openwhisk/openwhisk_annotations.html#annotations-specific-to-activations).

duration

INTEGER , optional

Time, in milliseconds, that it took for the activation to complete

end

STRING , optional

Time when the activation completed

logs

ARRAY , optional

Logs generated by the activation

name

STRING , optional

Name of the entity

namespace

STRING , optional

Namespace that the entity is in

publish

BOOLEAN , optional

Whether to publish the entity or not

response [ActivationResponse]

OBJECT , optional

Details on the response from the entity

start

STRING , optional

Time when the activation began

subject

STRING , optional

The user account that activated the item

version

STRING , optional

Semantic version of the item

result

OBJECT , optional

Return value from the activation

status

STRING , optional

Exit status of the activation

success

BOOLEAN , optional

Whether the action was successfully invoked

401

Unauthorized

Body

code

INTEGER , optional

error

STRING , optional

404

Not Found

Body

code

INTEGER , optional

error

STRING , optional

408

Request Timeout

Body

code

INTEGER , optional

error

STRING , optional

500

Internal Server Error

Body

code

INTEGER , optional

error

STRING , optional

Response example

200

Activation

								{
  "activationId" : string,
  "annotations" : [string],
  "duration" : integer,
  "end" : string,
  "logs" : [string],
  "name" : string,
  "namespace" : string,
  "publish" : boolean,
  "response" : {
    "result" : object,
    "status" : string,
    "success" : boolean
  },
  "start" : string,
  "subject" : string,
  "version" : string
}
							

401

Unauthorized

								{
  "code" : integer,
  "error" : string
}
							

404

Not Found

								{
  "code" : integer,
  "error" : string
}
							

408

Request Timeout

								{
  "code" : integer,
  "error" : string
}
							

500

Internal Server Error

								{
  "code" : integer,
  "error" : string
}
							

Loading content...

Resources