SP SPACEPLACE
EXAMPLE #15 PHP Bash

Soft-delete an event

Mark an event deleted (recoverable, ledger-preserving).

15-delete-event.php
#!/usr/bin/env php
<?php

/**
 * Example: Delete an event (soft delete)
 *
 * DELETE /api/events/{event-uuid}
 *
 * The event is soft-deleted and will no longer appear in queries.
 *
 * Usage:
 *   php 15-delete-event.php <event-uuid>
 */

$baseUrl       = 'https://www.spaceplace.app';
$dataStreamId  = 'YOUR-DATASTREAM-UUID-HERE';
$tokenValue    = 'YOUR-TOKEN-VALUE-HERE';

$eventId = $argv[1] ?? 'YOUR-EVENT-UUID-HERE';

$ch = curl_init("{$baseUrl}/api/events/{$eventId}");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'DELETE',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Accept: application/json',
        "X-DataStream-ID: {$dataStreamId}",
        "X-Token: {$tokenValue}",
    ],
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$body = json_decode($response, true);

if ($httpCode === 200) {
    echo "Event deleted: {$eventId}\n";
} elseif ($httpCode === 404) {
    echo "Event not found.\n";
} else {
    echo "Failed (HTTP {$httpCode}):\n";
    print_r($body);
}
15-delete-event.sh
#!/usr/bin/env bash
#
# Example: Delete an event (soft delete)
#
# DELETE /api/events/{event-uuid}
#
# The event is soft-deleted and will no longer appear in queries.
#
# Usage:
#   bash 15-delete-event.sh <event-uuid>

BASE_URL="https://www.spaceplace.app"
DATASTREAM_ID="YOUR-DATASTREAM-UUID-HERE"
TOKEN_VALUE="YOUR-TOKEN-VALUE-HERE"

EVENT_ID="${1:-YOUR-EVENT-UUID-HERE}"

response=$(curl -s -w "\n%{http_code}" \
  -X DELETE \
  -H "Accept: application/json" \
  -H "X-DataStream-ID: ${DATASTREAM_ID}" \
  -H "X-Token: ${TOKEN_VALUE}" \
  "${BASE_URL}/api/events/${EVENT_ID}")

http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')

if [ "$http_code" = "200" ]; then
  echo "Event deleted: ${EVENT_ID}"
elif [ "$http_code" = "404" ]; then
  echo "Event not found."
else
  echo "Failed (HTTP ${http_code}):"
  echo "$body" | jq .
fi
← All examples