Create a challenge in a community
curl --request POST \
--url https://api.cope.com/v1/community/communities/{id}/challenges \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cp_reward": 1,
"ends_at": "2023-11-07T05:31:56Z",
"starts_at": "2023-11-07T05:31:56Z",
"title": "<string>",
"deadline_timezone": "<string>",
"description": "<string>",
"goal_target": 2,
"prize_description": "<string>"
}
'import requests
url = "https://api.cope.com/v1/community/communities/{id}/challenges"
payload = {
"cp_reward": 1,
"ends_at": "2023-11-07T05:31:56Z",
"starts_at": "2023-11-07T05:31:56Z",
"title": "<string>",
"deadline_timezone": "<string>",
"description": "<string>",
"goal_target": 2,
"prize_description": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cp_reward: 1,
ends_at: '2023-11-07T05:31:56Z',
starts_at: '2023-11-07T05:31:56Z',
title: '<string>',
deadline_timezone: '<string>',
description: '<string>',
goal_target: 2,
prize_description: '<string>'
})
};
fetch('https://api.cope.com/v1/community/communities/{id}/challenges', 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.cope.com/v1/community/communities/{id}/challenges",
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([
'cp_reward' => 1,
'ends_at' => '2023-11-07T05:31:56Z',
'starts_at' => '2023-11-07T05:31:56Z',
'title' => '<string>',
'deadline_timezone' => '<string>',
'description' => '<string>',
'goal_target' => 2,
'prize_description' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cope.com/v1/community/communities/{id}/challenges"
payload := strings.NewReader("{\n \"cp_reward\": 1,\n \"ends_at\": \"2023-11-07T05:31:56Z\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"title\": \"<string>\",\n \"deadline_timezone\": \"<string>\",\n \"description\": \"<string>\",\n \"goal_target\": 2,\n \"prize_description\": \"<string>\"\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.cope.com/v1/community/communities/{id}/challenges")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cp_reward\": 1,\n \"ends_at\": \"2023-11-07T05:31:56Z\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"title\": \"<string>\",\n \"deadline_timezone\": \"<string>\",\n \"description\": \"<string>\",\n \"goal_target\": 2,\n \"prize_description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/community/communities/{id}/challenges")
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 \"cp_reward\": 1,\n \"ends_at\": \"2023-11-07T05:31:56Z\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"title\": \"<string>\",\n \"deadline_timezone\": \"<string>\",\n \"description\": \"<string>\",\n \"goal_target\": 2,\n \"prize_description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {}
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Create a challenge in a community
POST
/
v1
/
community
/
communities
/
{id}
/
challenges
Create a challenge in a community
curl --request POST \
--url https://api.cope.com/v1/community/communities/{id}/challenges \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cp_reward": 1,
"ends_at": "2023-11-07T05:31:56Z",
"starts_at": "2023-11-07T05:31:56Z",
"title": "<string>",
"deadline_timezone": "<string>",
"description": "<string>",
"goal_target": 2,
"prize_description": "<string>"
}
'import requests
url = "https://api.cope.com/v1/community/communities/{id}/challenges"
payload = {
"cp_reward": 1,
"ends_at": "2023-11-07T05:31:56Z",
"starts_at": "2023-11-07T05:31:56Z",
"title": "<string>",
"deadline_timezone": "<string>",
"description": "<string>",
"goal_target": 2,
"prize_description": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cp_reward: 1,
ends_at: '2023-11-07T05:31:56Z',
starts_at: '2023-11-07T05:31:56Z',
title: '<string>',
deadline_timezone: '<string>',
description: '<string>',
goal_target: 2,
prize_description: '<string>'
})
};
fetch('https://api.cope.com/v1/community/communities/{id}/challenges', 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.cope.com/v1/community/communities/{id}/challenges",
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([
'cp_reward' => 1,
'ends_at' => '2023-11-07T05:31:56Z',
'starts_at' => '2023-11-07T05:31:56Z',
'title' => '<string>',
'deadline_timezone' => '<string>',
'description' => '<string>',
'goal_target' => 2,
'prize_description' => '<string>'
]),
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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cope.com/v1/community/communities/{id}/challenges"
payload := strings.NewReader("{\n \"cp_reward\": 1,\n \"ends_at\": \"2023-11-07T05:31:56Z\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"title\": \"<string>\",\n \"deadline_timezone\": \"<string>\",\n \"description\": \"<string>\",\n \"goal_target\": 2,\n \"prize_description\": \"<string>\"\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.cope.com/v1/community/communities/{id}/challenges")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cp_reward\": 1,\n \"ends_at\": \"2023-11-07T05:31:56Z\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"title\": \"<string>\",\n \"deadline_timezone\": \"<string>\",\n \"description\": \"<string>\",\n \"goal_target\": 2,\n \"prize_description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/community/communities/{id}/challenges")
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 \"cp_reward\": 1,\n \"ends_at\": \"2023-11-07T05:31:56Z\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"title\": \"<string>\",\n \"deadline_timezone\": \"<string>\",\n \"description\": \"<string>\",\n \"goal_target\": 2,\n \"prize_description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {}
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"code": "<string>",
"errors": [
{
"code": "<string>",
"detail": "<string>",
"field": "<string>"
}
],
"status": 123,
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Authorizations
Bearer credential for the public API. Send a live COPE API key (cope_sk_live_*), or a Clerk session token when acting as a signed-in user. Community operations are scoped to the authenticated user; include X-Cope-Business-Id to act on behalf of a specific business you own.
Path Parameters
Pattern:
^[A-Za-z0-9_-]+$Body
application/json
Required range:
x >= 0Minimum string length:
1Minimum string length:
1Required range:
x >= 1Available options:
posts, comments, cp, streak, missions, custom Response
Created challenge
Was this page helpful?
⌘I