Set a campaign live or paused
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.grona.ai/v1/campaigns/CMP-1024/status"
payload := strings.NewReader("{ \"status\": \"live\" }")
req, _ := http.NewRequest("PATCH", 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(res) fmt.Println(string(body))
}OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{ \"status\": \"live\" }");Request request = new Request.Builder() .url("https://api.grona.ai/v1/campaigns/CMP-1024/status") .patch(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();const url = 'https://api.grona.ai/v1/campaigns/CMP-1024/status';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"status":"live"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://api.grona.ai/v1/campaigns/CMP-1024/status \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "status": "live" }'live runs the campaign and paused stops it. Any other value returns 400.
Grona rebuilds your site script after the change. Visitors see the new state once the refreshed script reaches them, so the change is not instant in either direction.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Grona’s campaign id or your externalId. If a value matches both, Grona’s id wins.
Example
CMP-1024Request Bodyrequired
Section titled “Request Bodyrequired”object
live runs the campaign. paused stops it. New campaigns start paused.
Example
{ "status": "live"}Responses
Section titled “Responses”The status after the change.
object
object
live runs the campaign. paused stops it. New campaigns start paused.
object
The workspace resolved from the secret key.
Example
{ "data": { "status": "live" }, "meta": { "workspaceId": "65e8a1c47d2f9b03e6a15c42" }}The campaign id is not valid, or status is not live or paused. error.code is
invalid_request. Nothing was changed.
object
object
Stable and machine-readable. Branch on this, and on the HTTP status for codes you do not know.
Human-readable. The wording can change, so do not parse it.
Example
{ "error": { "code": "invalid_request", "message": "`status` must be `live` or `paused`." }}The secret key is missing, malformed, unknown or revoked. error.code is unauthorized.
object
object
Stable and machine-readable. Branch on this, and on the HTTP status for codes you do not know.
Human-readable. The wording can change, so do not parse it.
Example
{ "error": { "code": "unauthorized", "message": "Missing or invalid API key." }}No campaign with this id or externalId exists in the key’s workspace. error.code is
not_found.
object
object
Stable and machine-readable. Branch on this, and on the HTTP status for codes you do not know.
Human-readable. The wording can change, so do not parse it.
Example
{ "error": { "code": "not_found", "message": "Campaign not found." }}Too many requests. Retry with exponential backoff and jitter, and wait at least as long
as Retry-After when it is present. Branch on the status code; the body is not
guaranteed to use the error envelope.
Headers
Section titled “Headers”How long to wait before retrying, in seconds or as an HTTP date.
Unexpected server error. error.code is internal_error. Retry with backoff; if it
persists, contact support@grona.ai with the time of the request and the endpoint.
object
object
Stable and machine-readable. Branch on this, and on the HTTP status for codes you do not know.
Human-readable. The wording can change, so do not parse it.
Example
{ "error": { "code": "internal_error", "message": "Something went wrong on our side." }}Temporarily unavailable. Retry with exponential backoff and jitter, and wait at least as
long as Retry-After when it is present. Branch on the status code; the body is not
guaranteed to use the error envelope.
Headers
Section titled “Headers”How long to wait before retrying, in seconds or as an HTTP date.