1. Create a Task

Create a Task

spaces/:space_id/tasks/

Path Parameters

  • :space_id

    required number

    Numeric id of a space

Request Body Properties

  • task

    The Task Object
    • id

      number

      Numeric ID of your task

    • name

      required string

      Given name of your task

    • description

      string

      A brief description of your task for your editors

    • task_type

      string

      Default: webhook; Currently available: webhook

    • webhook_url

      string

      URL of webhook that should be called when tasks is being executed

    • lambda_code

      string

      Beta: Lambda function code

Response Properties

  • task

    The Task Object
    • id

      number

      Numeric ID of your task

    • name

      string

      Given name of your task

    • description

      string

      A brief description of your task for your editors

    • task_type

      string

      Default: webhook; Currently available: webhook

    • last_execution

      string

      Date and time of last execution (Format: YYYY-mm-dd HH:MM)

    • webhook_url

      string

      URL of webhook that should be called when tasks is being executed

    • last_response

      string

      Last execution response log

    • lambda_code

      string

      Beta: Lambda function code

Request
curl "https://mapi.storyblok.com/v1/spaces/606/tasks/" \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: YOUR_OAUTH_TOKEN" \
  -d "{\"task\": {\"name\": \"My Task Name\",\"task_type\": \"webhook\",\"webhook_url\": \"https://www.storyblok.com\"}}"
Request
// Using the Universal JavaScript Client:
// https://github.com/storyblok/storyblok-js-client
Storyblok.post('/spaces/606/tasks/', {
  "task": {
    "name": "My Task Name",
    "task_type": "webhook",
    "webhook_url": "https://www.storyblok.com"
  }
})
  .then(response => {
    console.log(response)
  }).catch(error => { 
    console.log(error)
  })
Request
$client = new \Storyblok\Client('YOUR_STORYBLOK_SPACE_ACCESS_TOKEN');

$payload = [
  "task" =>  [
    "name" =>  "My Task Name",
    "task_type" =>  "webhook",
    "webhook_url" =>  "https => //www.storyblok.com"
  ]
];

$client->post('/spaces/606/tasks/', $payload)->getBody();
Request
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')

payload = {
  "task" =>  {
    "name" =>  "My Task Name",
    "task_type" =>  "webhook",
    "webhook_url" =>  "https => //www.storyblok.com"
  }
}

client.post('/spaces/606/tasks/', payload)
Request
HttpResponse<String> response = Unirest.post("https://mapi.storyblok.com/v1/spaces/606/tasks/")
  .header("Content-Type", "application/json")
  .header("Authorization", "YOUR_OAUTH_TOKEN")
  .body("{\"task\": {\"name\": \"My Task Name\",\"task_type\": \"webhook\",\"webhook_url\": \"https://www.storyblok.com\"}}")
  .asString();
Request
var client = new RestClient("https://mapi.storyblok.com/v1/spaces/606/tasks/");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");
request.AddParameter("application/json", "{\"task\": {\"name\": \"My Task Name\",\"task_type\": \"webhook\",\"webhook_url\": \"https://www.storyblok.com\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Request
import Foundation

let headers = [
  "Content-Type": "application/json",
  "Authorization": "YOUR_OAUTH_TOKEN"
]

let postData = NSData(data: "{\"task\": {\"name\": \"My Task Name\",\"task_type\": \"webhook\",\"webhook_url\": \"https://www.storyblok.com\"}}".data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://mapi.storyblok.com/v1/spaces/606/tasks/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)

request.method = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
Request
import requests

url = "https://mapi.storyblok.com/v1/spaces/606/tasks/"

querystring = {}

payload = "{\"task\": {\"name\": \"My Task Name\",\"task_type\": \"webhook\",\"webhook_url\": \"https://www.storyblok.com\"}}"
headers = {
  'Content-Type': "application/json",
  'Authorization': "YOUR_OAUTH_TOKEN"
}

response = requests.request("POST", url, data=payload, headers=headers, params=querystring)

print(response.text)