Action Instances

Before you can configure or run an action for a specific user and connection, an Action Instance needs to be created.
In many cases it is created automatically when you first try to access the action for a given connection.

Run

To run an action, do the following:

await integrationApp
  .connection('hubspot')
  .action('{ACTION_KEY}')
  .run('{INPUT}')
curl --request POST \
	--url https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/run \
	--header "Authorization: Bearer {CUSTOMER_TOKEN}" \
	--header "Content-Type: application/json" \
	--data '{INPUT}'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/run"
  payload := strings.NewReader("{INPUT}")
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/run"
  payload := strings.NewReader("{INPUT}")
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/run")
	.header("Authorization", "Bearer {CUSTOMER_TOKEN}")
	.header("Content-Type", "application/json")
	.body("{INPUT}")
	.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/run",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{INPUT}",
  CURLOPT_HTTPHEADER => [
    "Authorization" => "Bearer {CUSTOMER_TOKEN}",
    "Content-Type" => "application/json",
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

This request will return the result of the action that matches its outputSchema.

Get

await integrationApp
  .connection('hubspot')
  .action('{ACTION_KEY}')
  .get()
curl --request GET \
	--url https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY} \
	--header "Authorization: Bearer {CUSTOMER_TOKEN}"
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}"

headers = {
  "Authorization": "Bearer {CUSTOMER_TOKEN}"
}

response = requests.request("GET", url, headers=headers)

print(response.text)
HttpResponse<String> response = Unirest.get("https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}")
	.header("Authorization", "Bearer {CUSTOMER_TOKEN}")
	.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization" => "Bearer {CUSTOMER_TOKEN}",
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

List

To list all the actions for the current customer, do the following:

await integrationApp
  .connection('hubspot')
  .actions.list()
curl --request GET \
	--url https://api.integration.app/connections/{INTEGRATION_KEY}/actions \
	--header "Authorization: Bearer {CUSTOMER_TOKEN}"
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.integration.app/connections/{INTEGRATION_KEY}/actions"

headers = {
  "Authorization": "Bearer {CUSTOMER_TOKEN}"
}

response = requests.request("GET", url, headers=headers)

print(response.text)
HttpResponse<String> response = Unirest.get("https://api.integration.app/connections/{INTEGRATION_KEY}/actions")
	.header("Authorization", "Bearer {CUSTOMER_TOKEN}")
	.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.integration.app/connections/{INTEGRATION_KEY}/actions",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization" => "Bearer {CUSTOMER_TOKEN}",
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Update

To update a customer action, do the following:

await integrationApp
  .connection('hubspot')
  .action('{ACTION_KEY}')
  .patch('{INPUT}')
curl --request PATCH \
	--url https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY} \
	--header "Authorization: Bearer {CUSTOMER_TOKEN}" \
	--header "Content-Type: application/json" \
	--data '{INPUT}'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}"
  payload := strings.NewReader("{INPUT}")
  req, _ := http.NewRequest("PATCH", url, payload)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}"

headers = {
  "Authorization": "Bearer {CUSTOMER_TOKEN}",
  "Content-Type": "application/json"
}

payload = "{INPUT}"

response = requests.request("PATCH", url, headers=headers, json=payload)

print(response.text)
HttpResponse<String> response = Unirest.patch("https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}")
	.header("Authorization", "Bearer {CUSTOMER_TOKEN}")
	.header("Content-Type", "application/json")
	.body("{INPUT}")
	.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => "{INPUT}",
  CURLOPT_HTTPHEADER => [
    "Authorization" => "Bearer {CUSTOMER_TOKEN}",
    "Content-Type" => "application/json",
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Whenever you call this method, the action will be marked as customized (isCustomized set to true). To reset it back to default, use the reset method below.

Set up / Refresh

Setting up a customer action will re-fetch all the dependencies (data sources, schemas, etc.) and recalculate dynamic fields.

await integrationApp
  .connection('hubspot')
  .action('{ACTION_KEY}')
  .setup()
curl --request POST \
	--url https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/setup \
	--header "Authorization: Bearer {CUSTOMER_TOKEN}"
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/setup"
  req, _ := http.NewRequest("POST", url, nil)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/setup"

headers = {
  "Authorization": "Bearer {CUSTOMER_TOKEN}"
}

response = requests.request("POST", url, headers=headers)

print(response.text)
HttpResponse<String> response = Unirest.post("https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/setup")
	.header("Authorization", "Bearer {CUSTOMER_TOKEN}")
	.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/setup",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization" => "Bearer {CUSTOMER_TOKEN}",
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Reset

Resetting a customer action brings it to a default state, erasing all the customer-level configuration.

await integrationApp
  .connection('hubspot')
  .action('{ACTION_KEY}')
  .reset()
curl --request POST \
	--url https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/reset \
	--header "Authorization: Bearer {CUSTOMER_TOKEN}"
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/reset"
  req, _ := http.NewRequest("POST", url, nil)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/reset"

headers = {
  "Authorization": "Bearer {CUSTOMER_TOKEN}"
}

response = requests.request("POST", url, headers=headers)

print(response.text)
HttpResponse<String> response = Unirest.post("https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/reset")
	.header("Authorization", "Bearer {CUSTOMER_TOKEN}")
	.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}/reset",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization" => "Bearer {CUSTOMER_TOKEN}",
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Delete

await integrationApp
  .connection('hubspot')
  .action('{ACTION_KEY}')
  .archive()
curl --request DELETE \
	--url https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY} \
	--header "Authorization: Bearer {CUSTOMER_TOKEN}"
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}"
  req, _ := http.NewRequest("DELETE", url, nil)
  req.Header.Add("Authorization", "Bearer {CUSTOMER_TOKEN}")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}"

headers = {
  "Authorization": "Bearer {CUSTOMER_TOKEN}"
}

response = requests.request("DELETE", url, headers=headers)

print(response.text)
HttpResponse<String> response = Unirest.delete("https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}")
	.header("Authorization", "Bearer {CUSTOMER_TOKEN}")
	.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.integration.app/connections/{INTEGRATION_KEY}/actions/{ACTION_KEY}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => [
    "Authorization" => "Bearer {CUSTOMER_TOKEN}",
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}