Using the PayConex™ API

Overview

This section provides sample requests that demonstrate how to securely and effectively manage your API keys using the PayConex™ V4 API. Before diving into these examples, we recommend that you review the API Key Management via the PayConex™ UI for a visual UI understanding of the process.

More details on request parameters, responses and HTTP status codes can be found in the API References: Create API Key.

Creating an API Key

Below is an example JSON request body to create an API key.

POST /api/v4/accounts/{accountId}/api-keys

{
  "methods": [ "HMAC", "BASIC" ],
  "scopes": [
    "pcx:api_key:*",
    "pcx:iframe:*",
    "pcx:iframe:instance:*",
    "pcx:payments:*"
  ],
  "label": "Test-Example-Create-Key"
}

*Required Scopes: pcx:api_key:*, pcx:api_key:create

Response

{
  "id": "api_**********ba41f9abbea32a47428010",
  "secret": "503cbf**********9ac351219f5015ce",
  "label": "Test-Example-Create-Key",
  "methods": [
    "HMAC",
	"BASIC"
  ],
  "scopes": [
    "pcx:api_key:*",
	"pcx:iframe:*",
	"pcx:iframe:instance:*",
	"pcx:payments:*"
  ],
  "accountId": "220614966801",
  "createdAt": "2024-05-16T23:06:50.000000Z",
  "updatedAt": "2024-05-16T23:06:50.000000Z",
  "enabled": true
}

Getting API Key Details

GET /api/v4/accounts/{accountId}/api-keys/{resourceId}

*Required Scopes: pcx:api_key:*, pcx:api_key:read

📘

Note

Response

{
  "id": "api_**********ba41f9abbea32a47428010",
  "secret": "503cbf**********9ac351219f5015ce",
  "label": "Test-Example-Create-Key",
  "methods": [
    "HMAC",
    "BASIC"
  ],
  "scopes": [
    "pcx:api_key:*",
    "pcx:iframe:*",
    "pcx:iframe:instance:*",
    "pcx:payments:*"
  ],
  "accountId": "220614966801",
  "createdAt": "2024-05-16T23:06:50.000000Z",
  "updatedAt": "2024-05-16T23:06:50.000000Z",
  "enabled": true
}

The response is the same as in Creating an API Key.

Editing an API Key

📘

Note

  • The {resourceId} value in the path is the id of the API key to edit or update.

PATCH /api/v4/accounts/{accountId}/api-keys/{resourceId}

{
  "methods": [ "ALL" ],
  "scopes": [
    "pcx:api_key:*",
    "pcx:payments:*"
  ],
  "label": "Test-Example-Create-Key-Edited"
}

*Required Scopes: pcx:api_key:*, pcx:api_key:update

🚧

Note

In the case of editing scopes as above, the new scopes aren't appended to the existing API key; they are overwritten so make sure to keep the previous scopes by Getting API Key Details.

Also see Creating an API Key.

Deleting an API Key

📘

Note

  • The {resourceId} value in the path is the id of the API key to delete.

DELETE /api/v4/accounts/{accountId}/api-keys/{resourceId}

*Required Scopes: pcx:api_key:*, pcx:api_key:delete

Getting a list of API keys

Query Parameters

ParameterTypeDescriptionExample
pageintegerThe page number for the limit.Default: 1
limitintegerThe number of items to return in responseDefault: 100
querystringA query parameter that filters the dataset."API-Key-Test"

GET /api/v4/accounts/{accountId}/api-keys

*Required Scopes: pcx:api_key:*, pcx:api_key:read

Response

[  
  {
    "id": "api_**********29f4a4dada3d4d488befc8b",
    "label": "API-Key-Test",
    "methods": [
      "HMAC",
      "BASIC"
    ],
    "scopes": [
      "pcx:api_key:*",
      "pcx:iframe:*",
      "pcx:iframe:instance:*",
      "pcx:payments:*"
    ],
    "accountId": "220615031547",
    "createdAt": "2024-07-22T17:11:26.000000Z",
    "updatedAt": "2024-07-22T17:11:26.000000Z",
    "enabled": true
  },
  {
    "id": "api_**********9e426b8afd88bf74848c44",
    "label": "API-Key-Test",
    "methods": [
      "HMAC",
      "BASIC"
    ],
    "scopes": [
      "pcx:api_key:*",
      "pcx:iframe:*",
      "pcx:iframe:instance:*",
      "pcx:payments:*"
    ],
    "accountId": "220615031547",
    "createdAt": "2024-07-22T18:16:28.000000Z",
    "updatedAt": "2024-07-22T18:16:28.000000Z",
    "enabled": true
  },
  {
    "id": "api_**********794a4f9bf1f7376a2b2cf3",
    "label": "API-Key-Test",
    "methods": [
      "HMAC",
      "BASIC"
    ],
    "scopes": [
      "pcx:api_key:*",
      "pcx:iframe:*",
      "pcx:iframe:instance:*",
      "pcx:payments:*"
    ],
    "accountId": "220615031547",
    "createdAt": "2024-07-22T18:16:50.000000Z",
    "updatedAt": "2024-07-22T18:16:50.000000Z",
    "enabled": true
  }
]

🚧

Note

This action retrieves a list of API keys (excluding their secret values for security reasons). However, you can use the id of a specific API key to get its detailed information, including secret values, as shown in the API Key Details section above. This approach ensures that you can securely manage and review API keys while maintaining the confidentiality of sensitive authentication data.