MyTPEMyTPE Pay
API Keys

Generate API Key

Generate a new API key and secret for the authenticated user.

Generate API Key

Authentication Required

This endpoint requires authentication via Sanctum token.

HTTP Method & URL

POST https://dev.mytpe.app/api/api-keys/generate

Generate a new API key and secret for the authenticated user. This will delete any existing API keys.

Authentication

Authentication: Bearer Token (Authorization header)

You must include a valid Bearer token in the Authorization header.

Authorization: Bearer {your_token}

Request Parameters

Path Parameters

No path parameters required.

Query Parameters

No query parameters required.

Request Body

No request body required.

Example Request

generate-key.js
const response = await fetch('https://dev.mytpe.app/api/api-keys/generate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer {your_token}',
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  }
});

const data = await response.json();
console.log(data);
generate-key.ts
interface GenerateKeyResponse {
  success: boolean;
  message: string;
  data: {
    key: string;
    secret: string;
  };
}

const response = await fetch('https://dev.mytpe.app/api/api-keys/generate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer {your_token}',
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  }
});

const data: GenerateKeyResponse = await response.json();
console.log(data);
generate_key.py
import requests

response = requests.post(
    'https://dev.mytpe.app/api/api-keys/generate',
    headers={
        'Authorization': 'Bearer {your_token}',
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    }
)

data = response.json()
print(data)
generate-key.php
use Illuminate\Support\Facades\Http;

$response = Http::withHeaders([
    'Accept' => 'application/json',
])->withToken('{your_token}')
  ->post('https://dev.mytpe.app/api/api-keys/generate');

$data = $response->json();
generate-key.php
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://dev.mytpe.app/api/api-keys/generate',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer {your_token}',
        'Accept: application/json',
        'Content-Type: application/json',
    ],
]);

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

$data = json_decode($response, true);
print_r($data);
generate-key.cjs
const axios = require('axios');

axios.post('https://dev.mytpe.app/api/api-keys/generate', {}, {
    headers: {
      'Authorization': 'Bearer {your_token}',
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    }
  })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(error.response.data);
  });

Example Success Response

200 OK

{
    "success": true,
    "message": "API key generated successfully",
    "data": {
        "key": "MTP_KEY_KrJcNYpboUtfeHzHuRlDSSw2XYivO7ERwpiKbCz4",
        "secret": "MTP_SEC_XsmDGK9hGJEn1GzIHdosdaWdcqF4D53OsSQdafJg"
    }
}

Response Fields

Prop

Type

Error Responses

401 Unauthorized

{
    "success": false,
    "message": "Unauthenticated."
}

500 Internal Server Error

{
    "success": false,
    "message": "An error occurred while generating the API key."
}

Important Security Notice

The secret is only shown once upon generation. Make sure to store it securely immediately after receiving it. You will not be able to retrieve the secret again.

Destructive Action

Generating a new API key will delete all existing API keys associated with your account. Any integrations using the old keys will stop working immediately.

API Key Expiration

Generated API keys are valid for 1 year from the date of creation. Make sure to regenerate your keys before they expire to avoid service interruption.

On this page