> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# Calling PHP SDK methods and handling errors

> Making API calls through the PHP SDK requires calling defined methods in classes. The classes correspond to a group of endpoints that are used for feature areas.

## Calling PHP SDK methods and handling errors

> **Note**
>
> Learn about [Quickstart](/docs/esign-rest-api/quickstart) and how you can use it to quickly set up and run eSignature REST API code examples.

## Calling methods

Making API calls through the PHP SDK requires calling defined methods in public API classes. Each of these classes correspond to a group of endpoints that are used for specific feature areas related to the Docusign eSignature REST API.

Each specific REST endpoint typically has two different methods that can be used to call it. As an example, here are the two methods that can be used to make a call to update a brand:

```text
    AccountsApi\updateBrand($account_id, $brand_id, $brand = null)
    AccountsApi\updateBrandWithHttpInfo($account_id, $brand_id, $brand = null)
```

The difference between
[updateBrand](https://github.com/docusign/docusign-esign-php-client/blob/master/src/Api/AccountsApi.php#L6625) and
[updateBrandWithHttpInfo](https://github.com/docusign/docusign-esign-php-client/blob/master/src/Api/AccountsApi.php#L6642) is that the
`updateBrand` method returns only the JSON object that is being sent back from the API. On the other hand, the
`updateBrandWithHttpInfo` method provides both the body of the HTTP response (the JSON) as a generic object (in this case,
`Brand`) as well as the status code and the collection called
[headerParams](https://github.com/docusign/docusign-esign-php-client/blob/master/src/Api/AccountsApi.php#L1311) that includes all the HTTP headers in the response. These are useful to get additional information from the API—for example, information about
[API request limits](/docs/esign-rest-api/esign101/rules-and-limits)—that lives in the HTTP headers of the response.

**Note**: Unlike some
[Docusign eSignature SDKs](/docs/esign-rest-api/sdks) for other supported languages, the API classes in the PHP SDK do not natively support asynchronous method calls.

## Handling errors

Error handling is an important part of developing your software. Your code should handle both expected and unexpected errors.

The PHP SDK provides an
[ApiException](https://github.com/docusign/docusign-esign-php-client/blob/master/src/Client/ApiException.php#L41) class that is used for common scenarios where exceptions are thrown. The
[error_code](https://github.com/docusign/docusign-esign-php-client/blob/master/src/Model/ErrorDetails.php#L102) and
[message](https://github.com/docusign/docusign-esign-php-client/blob/master/src/Model/ErrorDetails.php#L103) properties can provide useful information to understand the cause of errors.

Common scenarios where the SDK throws an
`ApiException` are:

* Invalid or expired access token.

* HTTP response status code 400 and above. These represent various [error messages](/docs/esign-rest-api/esign101/error-codes) that are identified by the HTTP layer. Such errors include not authorized (403) errors, which occur as a result of issues with authentication.

* Issues in deserialization of the response JSON. If the JSON sent back by the API cannot be properly deserialized into the PHP objects that the SDK is expecting, an
  `ApiException` is thrown, and the "bad" JSON is returned in the
  `message` property of the exception.

* JWT issues with either the private RSA key pair or
  `user_id`. Since the
  `requestJWTUserToken` method for obtaining an OAuth token using JWT is included in the SDK, an
  `ApiException` is thrown if the RSA key or
  `user_id` is missing or malformed.

[Troubleshooting for common errors](/docs/esign-rest-api/esign101/error-codes/troubleshooting-common-errors) has detailed information about causes and resolutions for specific errors.

### Obtaining the trace token for solving problems via Support

Every API response includes a GUID that can be used to trace it on the back end by Docusign
[Support](https://support.docusign.com). This GUID is called the
*trace token*. The trace token enables Support staff to find the internal logs in the system related to the API request/response and get additional information about it. This information may not be directly available to developers with or without the SDK.

To obtain the trace token, you will first call the
`WithHttpInfo` variant of the method so that you retain the header of the HTTP response.

```bash
    $response = $accounts_api->updateBrandWithHttpInfo($account_id, $brand_id, $brand);
```

**Note**: Some API calls do not return an error, but instead provide error information inside the body of the HTTP response. In this case, you will need to have your code check the data returned from the API to ensure the call was successful.