Delete a campaign
package main
import ( "fmt" "net/http" "io")
func main() {
url := "https://api.grona.ai/v1/campaigns/CMP-1024"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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();
Request request = new Request.Builder() .url("https://api.grona.ai/v1/campaigns/CMP-1024") .delete(null) .addHeader("Authorization", "Bearer <token>") .build();
Response response = client.newCall(request).execute();const url = 'https://api.grona.ai/v1/campaigns/CMP-1024';const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request DELETE \ --url https://api.grona.ai/v1/campaigns/CMP-1024 \ --header 'Authorization: Bearer <token>'Deletes the campaign and the variations created with it. Deletion is permanent and frees
the campaign’s externalId for reuse. data.id is always Grona’s id, even when you call
it with your externalId.
If you retry a delete, address the campaign by Grona’s id, never by externalId. Once
the first attempt frees the externalId, a retry could delete a new campaign that took it.
Grona then removes the campaign from your site script. Visitors can still see it until the refreshed script reaches them, so the change is not instant.
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-1024Responses
Section titled “Responses”Deleted.
object
object
Grona’s id of the deleted campaign.
The variations deleted with the campaign.
object
The workspace resolved from the secret key.
Example
{ "data": { "id": "671a3c90e4b0a1f2c3d40011", "deletedVariationIds": [ "671a3c90e4b0a1f2c3d40012" ] }, "meta": { "workspaceId": "65e8a1c47d2f9b03e6a15c42" }}The request is invalid. error.code is invalid_request and error.message says what
to change. Nothing in the request was applied.
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": "The campaign id is not a valid id." }}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.