Newline53.Sdk
0.5.12
dotnet add package Newline53.Sdk --version 0.5.12
NuGet\Install-Package Newline53.Sdk -Version 0.5.12
<PackageReference Include="Newline53.Sdk" Version="0.5.12" />
<PackageVersion Include="Newline53.Sdk" Version="0.5.12" />
<PackageReference Include="Newline53.Sdk" />
paket add Newline53.Sdk --version 0.5.12
#r "nuget: Newline53.Sdk, 0.5.12"
#:package Newline53.Sdk@0.5.12
#addin nuget:?package=Newline53.Sdk&version=0.5.12
#tool nuget:?package=Newline53.Sdk&version=0.5.12
Newline .NET SDK
Developer-friendly and type-safe .NET SDK built to leverage the Newline Platform APIs.
Table of Contents
SDK Installation
Install the Newline SDK as a package in your .NET project:
dotnet package add Newline53.sdk
SDK Example Usage
Example
using Newline53.Sdk;
using Newline53.Sdk.Models.Components;
var sdk = new NewlineSDK(security: new Security() {
ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
HmacKey = "<YOUR_HMAC_KEY_HERE>",
});
var res = await sdk.Auth.GenerateTokenAsync();
// handle response
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
ProgramUid<br/>HmacKey |
http | Custom HTTP |
You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:
using Newline53.Sdk;
using Newline53.Sdk.Models.Components;
var sdk = new NewlineSDK(security: new Security() {
ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
HmacKey = "<YOUR_HMAC_KEY_HERE>",
});
var res = await sdk.Auth.GenerateTokenAsync();
// handle response
Available Resources and Operations
<details open> <summary>Available methods</summary>
Auth
- GenerateToken - Generate an authentication token
CombinedTransfers
- List - List Combined Transfers
- Create - Create a new Combined Transfer
- Get - Get a single Combined Transfer
CustodialAccounts
- List - List Custodial Accounts
- Get - Get a single Custodial Account
- ListClosingBalances - List Custodial Account Closing Balances
- GetClosingBalance - Get a single Custodial Account Closing Balance
CustomerProducts
- List - List Customer Products
- Onboard - Onboard Customer onto a Product
- Get - Get a single Customer Product
Customers
- List - Get a list of Customers
- Create - Create a new Customer
- Get - Get a single Customer
- Update - Adjust Customer Data
- Archive - Archive a Customer
Pools
Products
Returns
SyntheticAccounts
- ListTypes - List Synthetic Account Types
- GetAccountType - Get a Single Synthetic Account Type
- List - List Synthetic Accounts
- Create - Create a New Synthetic Account
- Get - Get a single Synthetic Account
- Update - Update the Synthetic Account metadata
- Archive - Archive a Synthetic Account
- ListClosingBalances - List Synthetic Account Closing Balances
- GetClosingBalance - Get a single Synthetic Account Closing Balance
Transactions
- List - List Transactions
- Get - Get a single Transaction
- Authorize - Approve or deny a transaction
- ListEvents - List Transaction Events
- GetEvent - Get a single Transaction Event
- ListSyntheticLines - List Synthetic Line Items
- GetSyntheticLineItem - Get a single Synthetic Line Item
- ListCustodialLines - List Custodial Line Items
- GetCustodialLineItem - Get a single Custodial Line Item
Transfers
- List - List Transfers
- Create - Initiate a Transfer
- Get - Get a single Transfer
- Cancel - Cancel a Transfer
VirtualReferenceNumbers
- List - List Virtual Reference Numbers
- Create - Create a new Virtual Reference Number
- Get - Get a single Virtual Reference Number
- Update - Edit a Virtual Reference Number
- Archive - Archive a single Virtual Reference Number
- Lock - Lock a single Virtual Reference Number
- Unlock - Unlock a single Virtual Reference Number
</details>
Error Handling
NewlineSDKException is the base exception class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
|---|---|---|
Message |
string | Error message |
Request |
HttpRequestMessage | HTTP request object |
Response |
HttpResponseMessage | HTTP response object |
Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.
Example
using Newline53.Sdk;
using Newline53.Sdk.Models.Components;
using Newline53.Sdk.Models.Errors;
using Newline53.Sdk.Models.Requests;
using System.Collections.Generic;
var sdk = new NewlineSDK(security: new Security() {
ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
HmacKey = "<YOUR_HMAC_KEY_HERE>",
});
try
{
OnboardCustomerProductRequest req = new OnboardCustomerProductRequest() {
CustomerUid = "S62MaHx6WwsqG9vQ",
ProductUid = "pQtTCSXz57fuefzp",
};
var res = await sdk.CustomerProducts.OnboardAsync(req);
// handle response
}
catch (NewlineSDKException ex) // all SDK exceptions inherit from NewlineSDKException
{
// ex.ToString() provides a detailed error message
System.Console.WriteLine(ex);
// Base exception fields
HttpRequestMessage request = ex.Request;
HttpResponseMessage response = ex.Response;
var statusCode = (int)response.StatusCode;
var responseBody = ex.Body;
if (ex is OnboardCustomerProductUnprocessableEntityException) // different exceptions may be thrown depending on the method
{
// Check error data fields
OnboardCustomerProductUnprocessableEntityExceptionPayload payload = ex.Payload;
List<OnboardCustomerProductError> Errors = payload.Errors;
long Status = payload.Status;
// ...
}
// An underlying cause may be provided
if (ex.InnerException != null)
{
Exception cause = ex.InnerException;
}
}
catch (OperationCanceledException ex)
{
// CancellationToken was cancelled
}
catch (System.Net.Http.HttpRequestException ex)
{
// Check ex.InnerException for Network connectivity errors
}
Error Classes
Primary exception:
NewlineSDKException: The base class for HTTP error responses.
<details><summary>Less common exceptions (34)</summary>
System.Net.Http.HttpRequestException: Network connectivity error. For more details about the underlying cause, inspect theex.InnerException.Inheriting from
NewlineSDKException:UpdateSyntheticAccountBadRequestException: A Synthetic Account is not updated if a required parameter is missing. Status code400. Applicable to 1 of 52 methods.*PutTransfersUidCancelBadRequestException: The transfer is not eligible for cancellation. Status code400. Applicable to 1 of 52 methods.*PutTransactionsUidAuthorizeBadRequestException: Bad authorization request. Status code400. Applicable to 1 of 52 methods.*PostReturnsBadRequestException: Creation Error. Status code400. Applicable to 1 of 52 methods.*PutTransactionsUidAuthorizeForbiddenException: Client authorization disabled. (The Program is not configured for Client Authorization). Status code403. Applicable to 1 of 52 methods.*GetReturnsForbiddenException: Denied access to Returns. Status code403. Applicable to 1 of 52 methods.*PostReturnsForbiddenException: Denied access to Returns. Status code403. Applicable to 1 of 52 methods.*GetReturnsUidForbiddenException: Denied access to Returns. Status code403. Applicable to 1 of 52 methods.*GetCombinedTransfersForbiddenException: Denied access to Combined Transfers. Status code403. Applicable to 1 of 52 methods.*PostCombinedTransfersForbiddenException: Denied access to Combined Transfers. Status code403. Applicable to 1 of 52 methods.*GetCombinedTransfersUidForbiddenException: Denied access to Combined Transfers. Status code403. Applicable to 1 of 52 methods.*GetVirtualReferenceNumbersUidNotFoundException: The Virtual Reference Number is not found. Status code404. Applicable to 1 of 52 methods.*PutVirtualReferenceNumbersUidNotFoundException: The Virtual Reference Number is not found. Status code404. Applicable to 1 of 52 methods.*DeleteVirtualReferenceNumbersUidNotFoundException: The Virtual Reference Number is not found. Status code404. Applicable to 1 of 52 methods.*PutVirtualReferenceNumbersUidLockNotFoundException: The Virtual Reference Number is not found. Status code404. Applicable to 1 of 52 methods.*PutVirtualReferenceNumbersUidUnlockNotFoundException: The Virtual Reference Number is not found. Status code404. Applicable to 1 of 52 methods.*GetReturnsUidNotFoundException: Unknown Return. Status code404. Applicable to 1 of 52 methods.*GetCombinedTransfersUidNotFoundException: The Combined Transfer is not found. Status code404. Applicable to 1 of 52 methods.*ConflictException: A new Synthetic Account is NOT created if the external_uid given is present but not unique. Status code409. Applicable to 1 of 52 methods.*OnboardCustomerProductUnprocessableEntityException: There was a problem with the request body. Status code422. Applicable to 1 of 52 methods.*DeleteSyntheticAccountUnprocessableEntityException: A Synthetic Account is not archived. Status code422. Applicable to 1 of 52 methods.*PutTransfersUidCancelUnprocessableEntityException: The transfer could not be canceled. Status code422. Applicable to 1 of 52 methods.*PutTransactionsUidAuthorizeUnprocessableEntityException: An exception occurred while authorizing transaction. Status code422. Applicable to 1 of 52 methods.*GetVirtualReferenceNumbersUnprocessableEntityException: Failed to retrieve Virtual Reference Numbers. Status code422. Applicable to 1 of 52 methods.*PostVirtualReferenceNumbersUnprocessableEntityException: Creation Error. Status code422. Applicable to 1 of 52 methods.*PutVirtualReferenceNumbersUidUnprocessableEntityException: Failed to update Virtual Reference Number. Status code422. Applicable to 1 of 52 methods.*PutVirtualReferenceNumbersUidLockUnprocessableEntityException: The Virtual Reference Number could not be locked. Status code422. Applicable to 1 of 52 methods.*PutVirtualReferenceNumbersUidUnlockUnprocessableEntityException: The Virtual Reference Number could not be unlocked. Status code422. Applicable to 1 of 52 methods.*GetReturnsUnprocessableEntityException: Failed to retrieve Returns. Status code422. Applicable to 1 of 52 methods.*PostReturnsUnprocessableEntityException: Creation Error. Status code422. Applicable to 1 of 52 methods.*GetCombinedTransfersUnprocessableEntityException: Failed to retrieve Combined Transfers. Status code422. Applicable to 1 of 52 methods.*PostCombinedTransfersUnprocessableEntityException: Creation Error. Status code422. Applicable to 1 of 52 methods.*ResponseValidationError: Thrown when the response data could not be deserialized into the expected type. </details>
* Refer to the relevant documentation to determine whether an exception applies to a specific operation.
Server Selection
Select Server by Name
You can override the default server globally by passing a server name to the server: string optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
| Name | Server | Description |
|---|---|---|
sandbox |
https://sandbox.newline53.com/api/v1 |
Sandbox |
prod |
https://api.newline53.com/api/v1 |
Production |
Example
using Newline53.Sdk;
using Newline53.Sdk.Models.Components;
var sdk = new NewlineSDK(
server: SDKConfig.Server.Sandbox,
security: new Security() {
ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
HmacKey = "<YOUR_HMAC_KEY_HERE>",
}
);
var res = await sdk.Auth.GenerateTokenAsync();
// handle response
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:
using Newline53.Sdk;
using Newline53.Sdk.Models.Components;
var sdk = new NewlineSDK(
serverUrl: "https://sandbox.newline53.com/api/v1",
security: new Security() {
ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
HmacKey = "<YOUR_HMAC_KEY_HERE>",
}
);
var res = await sdk.Auth.GenerateTokenAsync();
// handle response
Custom HTTP Client
The C# SDK makes API calls using an ISpeakeasyHttpClient that wraps the native
HttpClient. This
client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle
errors and response.
The ISpeakeasyHttpClient interface allows you to either use the default SpeakeasyHttpClient that comes with the SDK,
or provide your own custom implementation with customized configuration such as custom message handlers, timeouts,
connection pooling, and other HTTP client settings.
The following example shows how to create a custom HTTP client with request modification and error handling:
using Newline53.Sdk;
using Newline53.Sdk.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Create a custom HTTP client
public class CustomHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _defaultClient;
public CustomHttpClient()
{
_defaultClient = new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Add custom header and timeout
request.Headers.Add("x-custom-header", "custom value");
request.Headers.Add("x-request-timeout", "30");
try
{
var response = await _defaultClient.SendAsync(request, cancellationToken);
// Log successful response
Console.WriteLine($"Request successful: {response.StatusCode}");
return response;
}
catch (Exception error)
{
// Log error
Console.WriteLine($"Request failed: {error.Message}");
throw;
}
}
public void Dispose()
{
_httpClient?.Dispose();
_defaultClient?.Dispose();
}
}
// Use the custom HTTP client with the SDK
var customHttpClient = new CustomHttpClient();
var sdk = new NewlineSDK(client: customHttpClient);
<details> <summary>You can also provide a completely custom HTTP client with your own configuration:</summary>
using Newline53.Sdk.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Custom HTTP client with custom configuration
public class AdvancedHttpClient : ISpeakeasyHttpClient
{
private readonly HttpClient _httpClient;
public AdvancedHttpClient()
{
var handler = new HttpClientHandler()
{
MaxConnectionsPerServer = 10,
// ServerCertificateCustomValidationCallback = customCertValidation, // Custom SSL validation if needed
};
_httpClient = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(30)
};
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
return await _httpClient.SendAsync(request, cancellationToken ?? CancellationToken.None);
}
public void Dispose()
{
_httpClient?.Dispose();
}
}
var sdk = NewlineSDK.Builder()
.WithClient(new AdvancedHttpClient())
.Build();
</details>
<details> <summary>For simple debugging, you can enable request/response logging by implementing a custom client:</summary>
public class LoggingHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _innerClient;
public LoggingHttpClient(ISpeakeasyHttpClient innerClient = null)
{
_innerClient = innerClient ?? new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Log request
Console.WriteLine($"Sending {request.Method} request to {request.RequestUri}");
var response = await _innerClient.SendAsync(request, cancellationToken);
// Log response
Console.WriteLine($"Received {response.StatusCode} response");
return response;
}
public void Dispose() => _innerClient?.Dispose();
}
var sdk = new NewlineSDK(client: new LoggingHttpClient());
</details>
The SDK also provides built-in hook support through the SDKConfiguration.Hooks system, which automatically handles
BeforeRequestAsync, AfterSuccessAsync, and AfterErrorAsync hooks for advanced request lifecycle management.
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
License
See Also
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- newtonsoft.json (>= 13.0.3)
- nodatime (>= 3.1.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.12 | 107 | 7/23/2026 |