getneo
    getneo
    • Introduction
    • API examples
    • Technical topics
      • API structure
      • HTTP headers
      • Decoupled responses
      • Validation failures (418)
    • Endpoints
      • Auth
        • Get service bearer token (password)
          GET
        • Change tenant
          GET
        • End session
          GET
      • Counterparties
        • Get all counterparties
          GET
        • Get counterparty by ID
          GET
        • Get draft counterparty by ID
          GET
        • Submit counterparty draft
          POST
        • Update counterparty draft
          POST
        • Delete a counterparty draft
          DELETE
        • Add account to counterparty
          POST
        • Update counterparty account
          PATCH
        • Export counterparty data
          POST
      • Payments
        • Get all payments
          GET
        • Get a payment by ID
          GET
        • Make a payment (deposit, withdrawal or internal)
          POST

    API examples

    The scripts shown here are provided as examples of how to integrate the Neo API.
    These scripts are provided only as information and are not intended to be used in production environments.

    Authentication#

    Powershell
    This script will re-use an existing token or login for a new one, and return the account name and tenant name that is authenticated with that token.
    param (
        [Parameter(Mandatory = $true)][string]$user_id,
        [Parameter(Mandatory = $true)][string]$api_key
    )
    
    # NOTE: This example relies on the Neo reusable script
    .\Neo_reusable_script.ps1
    
    # Check if already logged in
    if ($script:bearerToken) {
        $response = (Invoke-SafeWebRequest -Method GET -Uri 'https://auth.getneo.com/api/v2/identity' -Headers @{ 'Authorization' = "Bearer $script:bearerToken" })
        if ($response.StatusCode -ne 200) {
            Write-Error "Failed to access Neo platform (identity = $($response.StatusCode))"
            return
        }
        if (-not $response.Content) {
            $script:bearerToken = $null
        }
    }
    
    # Log in
    if (-not $script:bearerToken) {
        $response = (Invoke-SafeWebRequest -Method GET -Uri "https://auth.getneo.com/api/v1/auth/login" -Headers @{ 'Authorization' = "Plaintext $user_id $api_key" })
        if ($response.StatusCode -eq 418) {
            Write-Error "Issue with login ($user_id): $((ConvertFrom-Json $response.Content).form.error)"
            return
        }
        if ($response.StatusCode -ne 200) {
            Write-Error "Failed to access Neo platform (auth/login = $($response.StatusCode))"
            return
        }
        if (-not $response.Headers.Authorization.StartsWith('Bearer')) {
            Write-Error "Service did not provide a bearer token"
            return
        }
        $script:bearerToken = $response.Headers.Authorization.Substring(7)
        Write-Host "Logged in: $user_id"
    }
    
    # Get current user info (same as response to auth/login)
    $response = (Invoke-SafeWebRequest -Method GET -Uri 'https://auth.getneo.com/api/v2/identity' -Headers @{ 'Authorization' = "Bearer ${script:bearerToken}" })
    if ($response.StatusCode -ne 200) {
        Write-Error "Token failed"
        $script:bearerToken = $null
        return
    }
    
    $id = (ConvertFrom-Json $response.Content)
    Write-Host "Current user: $($id.name)"
    Write-Host "Current tenant: $($id.currentClientName)"

    Reusable scripts#

    Powershell
    #.\Neo_reusable_script.ps1
    
    # Wrap Invoke-WebRequest to handle non-2xx responses better
    function Invoke-SafeWebRequest ([string]$Method, [string]$Uri, [PSObject]$Headers = $null, [PSObject]$Body = $null) {
        try {
            if ($Body) {
                return (Invoke-WebRequest -Method $Method -Uri $uri -Headers $Headers -Body $Body)
            } else {
                return (Invoke-WebRequest -Method $Method -Uri $uri -Headers $Headers)
            }
        } catch {
            return @{
                "StatusCode" = $_.Exception.Response.StatusCode;
                "StatusDescription" = $_.Exception.Response.StatusCode;
                "Headers" = $_.Exception.Response.Headers;
                "Content" = [IO.StreamReader]::new($_.Exception.Response.GetResponseStream()).ReadToEnd();
                "RawContentLength" = $_.Exception.Response.ContentLength;
            }
        }
    }
    Modified at 2025-07-01 15:06:29
    Previous
    Introduction
    Next
    API structure
    Built with