cURL
curl --request POST \
--url https://api.altur.io/api/v1.0/campaigns/{id}/{action} \
--header 'Authorization: <api-key>'import requests
url = "https://api.altur.io/api/v1.0/campaigns/{id}/{action}"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://api.altur.io/api/v1.0/campaigns/{id}/{action}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.altur.io/api/v1.0/campaigns/{id}/{action}",
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: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.altur.io/api/v1.0/campaigns/{id}/{action}"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.altur.io/api/v1.0/campaigns/{id}/{action}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.altur.io/api/v1.0/campaigns/{id}/{action}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"campaign": {
"id": 123,
"name": "<string>",
"integration": {
"id": "<string>"
},
"agent": {
"id": "<string>",
"name": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"scheduling": {
"mon": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"tue": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"wed": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"thu": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"fri": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sat": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sun": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
}
},
"cycles": {
"enabled": true,
"max_iterations": 7,
"cooldown_minutes": 720,
"filter_statuses": [
"<string>"
],
"filter_tags": [
"<string>"
],
"schedule": {
"mon": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"tue": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"wed": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"thu": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"fri": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sat": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sun": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
}
},
"schedule_start_date": "2023-12-25",
"schedule_end_date": "2023-12-25"
},
"analytics": {}
}
}{
"success": false,
"message": "<string>",
"field": "<string>"
}{
"error": 123,
"message": "<string>"
}{
"success": false,
"message": "<string>",
"field": "<string>"
}{
"success": false,
"message": "<string>",
"field": "<string>"
}{
"success": false,
"message": "<string>",
"field": "<string>",
"current_status": "<string>",
"valid_targets": [
"<string>"
]
}Campañas
Acciones de Ciclo de Vida
Aplica una acción de ciclo de vida a una Campaña. Acciones válidas: activate, pause, archive, resume. La acción es idempotente: aplicar una acción cuando la campaña ya está en el estado destino es un no-op exitoso.
POST
/
campaigns
/
{id}
/
{action}
cURL
curl --request POST \
--url https://api.altur.io/api/v1.0/campaigns/{id}/{action} \
--header 'Authorization: <api-key>'import requests
url = "https://api.altur.io/api/v1.0/campaigns/{id}/{action}"
headers = {"Authorization": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<api-key>'}};
fetch('https://api.altur.io/api/v1.0/campaigns/{id}/{action}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.altur.io/api/v1.0/campaigns/{id}/{action}",
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: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.altur.io/api/v1.0/campaigns/{id}/{action}"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.altur.io/api/v1.0/campaigns/{id}/{action}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.altur.io/api/v1.0/campaigns/{id}/{action}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"campaign": {
"id": 123,
"name": "<string>",
"integration": {
"id": "<string>"
},
"agent": {
"id": "<string>",
"name": "<string>"
},
"created_at": "2023-11-07T05:31:56Z",
"scheduling": {
"mon": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"tue": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"wed": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"thu": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"fri": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sat": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sun": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
}
},
"cycles": {
"enabled": true,
"max_iterations": 7,
"cooldown_minutes": 720,
"filter_statuses": [
"<string>"
],
"filter_tags": [
"<string>"
],
"schedule": {
"mon": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"tue": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"wed": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"thu": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"fri": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sat": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
},
"sun": {
"startTime": "<string>",
"stopTime": "<string>",
"active": true
}
},
"schedule_start_date": "2023-12-25",
"schedule_end_date": "2023-12-25"
},
"analytics": {}
}
}{
"success": false,
"message": "<string>",
"field": "<string>"
}{
"error": 123,
"message": "<string>"
}{
"success": false,
"message": "<string>",
"field": "<string>"
}{
"success": false,
"message": "<string>",
"field": "<string>"
}{
"success": false,
"message": "<string>",
"field": "<string>",
"current_status": "<string>",
"valid_targets": [
"<string>"
]
}Límite de Tasa: 12 solicitudes por segundo
action es uno de activate, pause, archive, resume.
Transiciones Válidas
| Acción | Estados de origen permitidos | Efecto |
|---|---|---|
activate | pending, ready, cooldown | establece status → active |
pause | active, cooldown | establece status → inactive |
resume | inactive | establece status → active |
archive | cualquiera | establece archived = true |
Idempotencia
archivesiempre es exitoso. Re-archivar una campaña es un no-op.pauseen una campaña yainactive, yresumeen una campaña yaactive, son no-ops exitosos.activateno es idempotente: llamarlo en una campaña ya enactive(oinactive, ofinished) devuelve409 INVALID_STATUS_TRANSITIONporqueactiveno está en los orígenes permitidos. Usaresumepara reactivar una campaña pausada.
Errores
400 UNKNOWN_ACTION:actionno es uno de los valores soportados.402 BILLING_LIMIT_REACHED:activateoresumey se alcanzó el límite del plan.409 INVALID_STATUS_TRANSITION: el estado actual no está en los orígenes permitidos. La respuesta incluyecurrent_statusyvalid_targets.
Ejemplos
curl -X POST "https://api.altur.io/api/v1.0/campaigns/1234/activate" \
-H "Authorization: api-key YOUR_API_SECRET_KEY"
import requests
response = requests.post(
"https://api.altur.io/api/v1.0/campaigns/1234/activate",
headers={"Authorization": "api-key YOUR_API_SECRET_KEY"},
)
response.raise_for_status()
campaign = response.json()["campaign"]
const res = await fetch(
"https://api.altur.io/api/v1.0/campaigns/1234/activate",
{
method: "POST",
headers: { Authorization: "api-key YOUR_API_SECRET_KEY" },
},
);
const { campaign } = await res.json();
Autorizaciones
Add api-key YOUR_API_SECRET_KEY as the value of the Authorization header.
Parámetros de ruta
The identifier of the Campaign
Lifecycle action to apply
Opciones disponibles:
activate, pause, archive, resume ⌘I