Create an activity
curl --request POST \
--url https://api.smile.io/v1/activities \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"activity": {
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z"
}
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.smile.io/v1/activities"
payload := strings.NewReader("{\n \"activity\": {\n \"customer_id\": 304169228,\n \"token\": \"activity_f57a9b5a8d0ac5\",\n \"distinct_id\": \"212993\",\n \"created_on_origin_at\": \"2024-04-04T15:10:42.030Z\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.smile.io/v1/activities")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"activity\": {\n \"customer_id\": 304169228,\n \"token\": \"activity_f57a9b5a8d0ac5\",\n \"distinct_id\": \"212993\",\n \"created_on_origin_at\": \"2024-04-04T15:10:42.030Z\"\n }\n}")
.asString();const url = 'https://api.smile.io/v1/activities';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
activity: {
customer_id: 304169228,
token: 'activity_f57a9b5a8d0ac5',
distinct_id: '212993',
created_on_origin_at: '2024-04-04T15:10:42.030Z'
}
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.smile.io/v1/activities",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'activity' => [
'customer_id' => 304169228,
'token' => 'activity_f57a9b5a8d0ac5',
'distinct_id' => '212993',
'created_on_origin_at' => '2024-04-04T15:10:42.030Z'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <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;
}$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.smile.io/v1/activities' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"activity": {
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z"
}
}'import requests
url = "https://api.smile.io/v1/activities"
payload = { "activity": {
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://api.smile.io/v1/activities")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"activity\": {\n \"customer_id\": 304169228,\n \"token\": \"activity_f57a9b5a8d0ac5\",\n \"distinct_id\": \"212993\",\n \"created_on_origin_at\": \"2024-04-04T15:10:42.030Z\"\n }\n}"
response = http.request(request)
puts response.read_body{
"activity": {
"id": 503256787,
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z",
"created_at": "2024-05-15T08:35:08.920Z",
"updated_at": "2024-05-15T08:35:08.920Z"
}
}Activities
Create an activity
Creates a record of a customer having performed a given action.
POST
/
activities
Create an activity
curl --request POST \
--url https://api.smile.io/v1/activities \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"activity": {
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z"
}
}
'package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.smile.io/v1/activities"
payload := strings.NewReader("{\n \"activity\": {\n \"customer_id\": 304169228,\n \"token\": \"activity_f57a9b5a8d0ac5\",\n \"distinct_id\": \"212993\",\n \"created_on_origin_at\": \"2024-04-04T15:10:42.030Z\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.smile.io/v1/activities")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"activity\": {\n \"customer_id\": 304169228,\n \"token\": \"activity_f57a9b5a8d0ac5\",\n \"distinct_id\": \"212993\",\n \"created_on_origin_at\": \"2024-04-04T15:10:42.030Z\"\n }\n}")
.asString();const url = 'https://api.smile.io/v1/activities';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
activity: {
customer_id: 304169228,
token: 'activity_f57a9b5a8d0ac5',
distinct_id: '212993',
created_on_origin_at: '2024-04-04T15:10:42.030Z'
}
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.smile.io/v1/activities",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'activity' => [
'customer_id' => 304169228,
'token' => 'activity_f57a9b5a8d0ac5',
'distinct_id' => '212993',
'created_on_origin_at' => '2024-04-04T15:10:42.030Z'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <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;
}$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.smile.io/v1/activities' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"activity": {
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z"
}
}'import requests
url = "https://api.smile.io/v1/activities"
payload = { "activity": {
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://api.smile.io/v1/activities")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"activity\": {\n \"customer_id\": 304169228,\n \"token\": \"activity_f57a9b5a8d0ac5\",\n \"distinct_id\": \"212993\",\n \"created_on_origin_at\": \"2024-04-04T15:10:42.030Z\"\n }\n}"
response = http.request(request)
puts response.read_body{
"activity": {
"id": 503256787,
"customer_id": 304169228,
"token": "activity_f57a9b5a8d0ac5",
"distinct_id": "212993",
"created_on_origin_at": "2024-04-04T15:10:42.030Z",
"created_at": "2024-05-15T08:35:08.920Z",
"updated_at": "2024-05-15T08:35:08.920Z"
}
}This endpoint requires the scope.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
- With customer ID
- With customer email
Show child attributes
Show child attributes
Response
201 - application/json
The activity was successfully created.
Show child attributes
Show child attributes
⌘I