# Get a Customer Fetching a Customer is pretty straightforward. To retrieve a resource in commercetools, you must provide either the `id` or `key` as the identifier of the resource. For Customers, you can find information for either of these two approaches under [Get Customer](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcustomers%2F%7Bid%7D%3AGET). For multi-language SDK code snippets for querying Customers, see [SDK example code](https://docs.commercetools.com/learning-composable-commerce-developer-essentials/dev-tooling/sdk-example-code.md#query-a-customer). After we fetch the Customer, we receive a Customer response object which contains the fields as described in the [Customer representation](https://docs.commercetools.com/api/projects/customers.md#customer). Image url: https://docs.commercetools.com/learning-composable-commerce-developer-essentials/images/manage-resources-with-the-sdk/docs-customer.png Alt text: The docs representation page shows what possible fields exist for Customer. A successful response will contain the requested data body in JSON format: ```json { "id": "cfab735c-2693-4a27-980c-921686c6750b", "version": 1, "createdAt": "2024-01-16T06:00:31.099Z", "lastModifiedAt": "2024-01-16T06:00:31.099Z", "lastModifiedBy": { "clientId": "VdkVvQ_2M82WsxJFU3A8A6Fz", "isPlatformClient": false }, "createdBy": { "clientId": "VdkVvQ_2M82WsxJFU3A8A6Fz", "isPlatformClient": false }, "email": "example-customer@example.com", "firstName": "John", "lastName": "Doe", "password": "**removed from output**", "addresses": [ { "id": "yUmV0kHa", "firstName": "John", "lastName": "Doe", "country": "US", "key": "john-doe-example-home" } ], "shippingAddressIds": [], "billingAddressIds": [], "isEmailVerified": false, "key": "john-doe-example", "stores": [], "authenticationMode": "Password" } ``` ## Use the SDKs Create a file called `customerFetchByKey.js` and copy the following code: ```typescript import { apiRoot } from '../impl/apiClient.js'; // Update to map to your API root const customerKey = 'abc'; async function customerFetchById(customerKey) { try { const response = await apiRoot .customers() .withKey({ key: customerKey, }) .get() .execute(); console.log('Success', JSON.stringify(response.body, null, 2)); } catch (error) { console.log(JSON.stringify(error, null, 2)); } } customerFetchById(customerKey); ``` In the following code we have combined the code snippets from the service and exercise class. Make sure you place the code into the correct files and add import statements as needed. ```java CustomerService: public CompletableFuture> getCustomerByKey(String customerKey) { return apiRoot .customers() .withKey(customerKey) .get() .execute(); } CustomerExercise: logger.info("Customer fetch: " + customerService .getCustomerByKey("john-doe-example") .toCompletableFuture().get() .getBody().getEmail() ); ``` We trust that by now you can run the above code and fetch the Customer from your Project. If you’re still having trouble, you can review the relevant section in the Prepare your work environment module where we execute a similar fetch request. ## Related pages - [Section overview page](https://docs.commercetools.com/learning-composable-commerce-developer-essentials.md) - [Previous page: Create a Customer](https://docs.commercetools.com/learning-composable-commerce-developer-essentials/manage-resources-with-the-sdk/create-a-customer.md) - [Next page: Update a Customer](https://docs.commercetools.com/learning-composable-commerce-developer-essentials/manage-resources-with-the-sdk/update-a-customer.md)