Skip to content

Abonnement Stoppen

Stoppt ein aktives Abonnement über die interne ID oder externe ID. Nur Abonnements ohne Transaktionslimits können gestoppt werden.

POST /v1/subscription/stop

Anfrage

Entweder die interne Abonnement-ID (id) oder die externe ID (external_id) muss angegeben werden.

Anfrage-Parameter

FeldTypErforderlichBeschreibung
idstringNein*Abonnement-ID
external_idstringNein*Externe Abonnement-ID

* Mindestens einer der Parameter muss angegeben werden: id oder external_id

bash
#!/bin/bash
API_TOKEN="your_api_token"
API_SECRET="your_api_secret"
REQUEST_BODY='{
  "id": "01k33rz57drtqgqcedyn9tvk04"
}'

# Calculate signature
SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1)

# Execute API request
curl -X POST "https://api.tronzap.com/v1/subscription/stop" \
  -H "Authorization: Bearer ${API_TOKEN}" \
  -H "X-Signature: ${SIGNATURE}" \
  -H "Content-Type: application/json" \
  -d "${REQUEST_BODY}"
javascript
const crypto = require('crypto');
const axios = require('axios');

const apiToken = 'your_api_token';
const apiSecret = 'your_api_secret';
const requestBody = JSON.stringify({
  id: "01k33rz57drtqgqcedyn9tvk04"
});

// Calculate signature
const signature = crypto
  .createHash('sha256')
  .update(requestBody + apiSecret)
  .digest('hex');

// Execute API request
axios({
  method: 'post',
  url: 'https://api.tronzap.com/v1/subscription/stop',
  headers: {
    'Authorization': `Bearer ${apiToken}`,
    'X-Signature': signature,
    'Content-Type': 'application/json'
  },
  data: requestBody
})
.then(response => console.log(response.data))
.catch(error => console.error(error));
php
<?php
$apiToken = 'your_api_token';
$apiSecret = 'your_api_secret';
$requestBody = json_encode([
  'id' => "01k33rz57drtqgqcedyn9tvk04"
]);

// Calculate signature
$signature = hash('sha256', $requestBody . $apiSecret);

// Execute API request
$ch = curl_init('https://api.tronzap.com/v1/subscription/stop');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Authorization: Bearer ' . $apiToken,
  'X-Signature: ' . $signature,
  'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
python
import hashlib
import json
import requests

api_token = 'your_api_token'
api_secret = 'your_api_secret'
request_body = json.dumps({
  'id': "01k33rz57drtqgqcedyn9tvk04"
})

# Calculate signature
signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest()

# Execute API request
headers = {
  'Authorization': f'Bearer {api_token}',
  'X-Signature': signature,
  'Content-Type': 'application/json'
}

response = requests.post(
  'https://api.tronzap.com/v1/subscription/stop',
  headers=headers,
  data=request_body
)

print(response.json())

Beispiel-Anfrage mit externer ID

bash
#!/bin/bash
API_TOKEN="your_api_token"
API_SECRET="your_api_secret"
REQUEST_BODY='{
  "external_id": "my-subscription-123"
}'

# Calculate signature
SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1)

# Execute API request
curl -X POST "https://api.tronzap.com/v1/subscription/stop" \
  -H "Authorization: Bearer ${API_TOKEN}" \
  -H "X-Signature: ${SIGNATURE}" \
  -H "Content-Type: application/json" \
  -d "${REQUEST_BODY}"
javascript
const crypto = require('crypto');
const axios = require('axios');

const apiToken = 'your_api_token';
const apiSecret = 'your_api_secret';
const requestBody = JSON.stringify({
  external_id: 'my-subscription-123'
});

// Calculate signature
const signature = crypto
  .createHash('sha256')
  .update(requestBody + apiSecret)
  .digest('hex');

// Execute API request
axios({
  method: 'post',
  url: 'https://api.tronzap.com/v1/subscription/stop',
  headers: {
    'Authorization': `Bearer ${apiToken}`,
    'X-Signature': signature,
    'Content-Type': 'application/json'
  },
  data: requestBody
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

Antwort

Die Antwort enthält Informationen über das gestoppte Abonnement.

Antwort-Felder

FeldTypBeschreibung
codeintegerAntwortcode (0 = erfolgreich)
resultobjectAntwortdaten
result.idstringAbonnement-ID
result.subscription_idstringAbonnement-Typ-ID
result.created_atstringErstellungsdatum (ISO 8601 Format)
result.stopped_atstringStoppdatum (ISO 8601 Format)
result.statusstringAbonnement-Status (sollte "stopped" sein)
result.external_idstringExterne Abonnement-ID (falls angegeben)
result.paramsobjectUrsprüngliche Anfrage-Parameter

Antwort-Beispiel

json
{
    "code": 0,
    "result": {
        "id": "01k33rz57drtqgqcedyn9tvk04",
        "subscription_id": "energy_monthly_unlimited",
        "created_at": "2024-03-22T12:00:00Z",
        "stopped_at": "2024-03-25T10:30:00Z",
        "status": "stopped",
        "external_id": "my-subscription-123",
        "params": {
            "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
            "duration": 30,
            "transactions_limit": 0,
            "activate_address": true
        }
    }
}

Mögliche Fehler

FehlercodeBeschreibung
1Authentifizierungsfehler (ungültiger Token oder Signatur)
2Ungültiger Service oder Parameter
20Abonnement nicht gefunden
21Abonnement kann nicht gestoppt werden (Abonnement hat Transaktionslimit)
500Interner Serverfehler

Tron Energy API Documentation