--- title: "JavaScript Library" slug: "javascript-library" updated: 2025-10-07T09:58:28Z published: 2025-10-07T10:28:11Z canonical: "help.mail-and-deploy.com/javascript-library" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.mail-and-deploy.com/llms.txt > Use this file to discover all available pages before exploring further. # JavaScript Library ### General The JavaScript library consists of a file named *MailAndDeploy.Api.Client.js* located in the *SDK\Library* folder of the root installation directory. It provides high-level functionality to access the API. ### Initialization Before any API call can be performed, the following syntax can be used to initialize the API connector: Connector Initialization MailAndDeployApiClient.InitializeConnector(EndpointUrl, AccessKey) You have to pass the endpoint URL (that is the URL of the API [Service](/release36/docs/services)) and the access key for the [User](/release36/docs/users) to authenticate. ### Making API Calls Once the initialization has been completed, you can call any [API Method](/release36/docs/methods) by using the following syntax: API Method Call MailAndDeployApiClient.(, ... ) The return value of such a call will be a *Promise*. API Method Call MailAndDeployApiClient.(, ... ).then(function(Response) {...}); ### Examples The following example returns a *DatasourceStructure* that represents the [Datasource](/release36/docs/introduction-2) with ID 947667f3-665b-4246-8073-95de881225b1: GetDatasource Example var Datasource = null; MailAndDeployApiClient.GetDatasource('947667f3-665b-4246-8073-95de881225b1').then(function(Response) {Datasource = Response}); The following code changes the name of the queried datasource to *MyDatasource* and then persists it: Persist Example Datasource.Name = 'MyDatasource'; await MailAndDeployApiClient.Persist(Datasource); ### Global Error Handling When reacting to the rejection of a *Promise*, error handling can be done for every call individually. In some cases, however, it's better to have a single global error handling function which is called regardless of which API call leads to the error. This can be implemented using the following syntax: Global Error Handler MailAndDeployApiClient.OnError = function(ErrorMsg) {...}