# Merchant Ingestion
source: https://developer.mastercard.com/eop-admin/documentation/use-cases/merchants/index.md

## Create Merchant {#create-merchant}

This API provides the ability to ingest Merchant based on the source and category data. Refer to the [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md) page for further information about each endpoint.

### Prerequisites {#prerequisites}

Refer to the following prerequisites for the customer to use this endpoint:

* The [source data](https://developer.mastercard.com/eop-admin/documentation/use-cases/sources/index.md) should exist for Merchant creation.
* The [categories](https://developer.mastercard.com/eop-admin/documentation/use-cases/categories/index.md) should exist for the Merchant country to create the Merchant.

### Sequence diagram {#sequence-diagram}

Diagram merchant_create

### Execution steps {#execution-steps}

1. The Merchant aggregator sends the create request to Merchant Ingestion API with parameters in the request payload [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
2. Mastercard Gateway validates the client request.
3. Mastercard Gateway routes the POST /merchants request to Merchant Ingestion API in the case of valid request.
4. The request is validated with the application permissions using the key from the header.
5. The POST /merchants request creates the Merchant and returns a successfully created response (201).
6. The Merchant Ingestion API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure}


API Reference: `GET /merchants`

## Update Merchant {#update-merchant}

The Update Merchant API provides the ability to update the Merchant based on the category and some metadata. It can be used to deactivate the Merchant. Refer to the [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md) page for further information about each endpoint.

### Prerequisites {#prerequisites-1}

Refer to the following prerequisites for the customer to use this endpoint:

* The merchant data should exist for Merchant update.
* The [categories](https://developer.mastercard.com/eop-admin/documentation/use-cases/categories/index.md) should exist for the Merchant country to update the Merchant.

### Sequence diagram {#sequence-diagram-1}

Diagram merchant_update

### Execution steps {#execution-steps-1}

1. The Merchant aggregator sends the update request to Merchant Update API with parameters in the request payload [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
2. Mastercard Gateway validates the client request.
3. Mastercard Gateway routes the PUT /merchants/{uuid} request to the Merchant Update API in the case of valid request.
4. The request is validated with the application permissions using the key from the header.
5. The PUT /merchants/{uuid} request updates the Merchant and returns successful response (200).
6. The Merchant Update API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure-1}


API Reference: `GET /merchants/{merchant_id}`

## Get Merchant {#get-merchant}

The Get Merchant API retrieves Merchant details if the Merchant exists. The API requires the Merchant unique identifier ID to return the details. Refer to the [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md) page for further information about each endpoint.

### Prerequisites {#prerequisites-2}

Refer to the following prerequisites for the customer to use this endpoint:

* The Merchant should exist in the system to return the successful response. It fetches a single Merchant detail by using Merchant UUID (Universal Unique Identifier).

### Sequence diagram {#sequence-diagram-2}

Diagram merchant_get

### Execution steps {#execution-steps-2}

1. The Merchant aggregator sends the fetch request to Merchant API with the path parameter Merchant UUID (Universal Unique Identifier) in the url.
2. Mastercard Gateway validates the client request.
3. Mastercard Gateway routes the GET /merchants/{uuid} request to Merchant API in the case of valid request.
4. The request is validated with the application permissions using the key from the header.
5. The GET /merchants/{uuid} request fetches the Merchant details if it exists and returns a success response (200).
6. The Merchant API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure-2}


API Reference: `GET /merchants/{merchant_id}`

## Add Merchant Media {#add-merchant-media}

Add Merchant Media adds Merchant images, such as logo and lifestyle images, which are used to create an offer. The images are later resized based on the configurations set by the Publishers. Refer to the [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md) page for further information about each endpoint.

### Prerequisites {#prerequisites-3}

Refer to the following prerequisites for the customer to use this endpoint:

* Adding media is only for existing Merchants so, the Merchant should be created to ingest images for Merchant using [merchant ingestion](https://developer.mastercard.com/eop-admin/documentation/use-cases/merchants/index.md) flow.

### Upload image less than 900 KB {#upload-image-less-than-900-kb}

#### Sequence diagram {#sequence-diagram-3}

Diagram merchant_media

#### Execution steps {#execution-steps-3}

1. The Merchant aggregator sends the create request to Add Merchant Media API with path parameter Merchant UUID (Universal Unique Identifier) in the url and other parameters in the request payload at [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
2. Mastercard Gateway validates the client request.
3. Mastercard Gateway routes the POST /merchants/{uuid}/images request to Add Merchant Media API in the case of valid request.
4. The request is validated with the application permissions using the key from the header.
5. The POST /merchants/{uuid}/images request adds media to the Merchant and returns a successfully created response (201).
6. The Add Merchant Media API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure-3}


API Reference: `GET /merchants/{merchant_id}/images`

### Upload image greater than 900 KB by parts {#upload-image-greater-than-900-kb-by-parts}

#### Sequence diagram {#sequence-diagram-4}

Diagram merchant_media_large

#### Execution steps {#execution-steps-4}

1. The Merchant aggregator sends multiple "/merchants/{merchant_id}/images/parts" request to upload all parts of large image and "merchants/{merchant_id}/images/parts/joins" request to join previously uploaded image parts. ([example-of-splitting-the-large-image-and-upload-it-by-parts](https://developer.mastercard.com/eop-admin/documentation/tutorials-and-guides/index.md#example-of-splitting-the-large-image-and-upload-it-by-parts))
2. Upload image part Merchant Media API request must contain the path parameter Merchant UUID (Universal Unique Identifier) in the url and other parameters in the request payload at [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
3. Mastercard Gateway validates the client request.
4. Mastercard Gateway routes the POST /merchants/{merchant_id}/images/parts request to Add Merchant Media API in the case of valid request.
5. The request is validated with the application permissions using the key from the header.
6. The POST /merchants/{merchant_id}/images/parts request adds media to the Merchant and returns a successfully created response (201).
7. The upload Merchant Media part API returns a response with a status code of 4XX/5XX in case of an invalid request.
8. Join image parts Merchant Media API request must contain the path parameter Merchant UUID (Universal Unique Identifier) in the url and other parameters in the request payload at [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
9. Mastercard Gateway validates the client request.
10. Gateway routes the POST /merchants/{merchant_id}/images/parts/joins request to Add Merchant Media API in the case of valid request.
11. The request is validated with the application permissions using the key from the header.
12. The POST /merchants/{merchant_id}/images/parts/joins request adds media to the Merchant and returns a successfully created response (201).
13. The join Merchant Media API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure-4}


API Reference: `GET /merchants/{merchant_id}/images/parts`


API Reference: `GET /merchants/{merchant_id}/images/parts/joins`

<br />

## Update Merchant Media {#update-merchant-media}

Update Merchant Media updates Merchant images, such as logo and lifestyle images, which are used to create an offer. The image update is used to deactivate the image, and a new image is uploaded. Refer to the [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md) page for further information about each endpoint.

### Prerequisites {#prerequisites-4}

Refer to the following prerequisites for the customer to use this endpoint:

* Updating media is only applicable to existing Merchants and images, so both must already exist. The Merchant and image should be crated using the [merchant ingestion](https://developer.mastercard.com/eop-admin/documentation/use-cases/merchants/index.md) flow.

### Sequence diagram {#sequence-diagram-5}

Diagram merchant_media_update

### Execution steps {#execution-steps-5}

1. The Merchant aggregator sends the update request to Update Merchant Media API with path parameter Merchant UUID (Universal Unique Identifier) and image UUID (Universal Unique Identifier) in the url and other parameters in the request payload at [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
2. Mastercard Gateway validates the client request.
3. Mastercard Gateway routes the PUT /merchants/{uuid}/images/{uuid} request to Update Merchant Media API in the case of valid request.
4. The request is validated with the application permissions using the key from the header.
5. The PUT /merchants/{uuid}/images/{uuid} request updates media to the Merchant and returns a successful response (200).
6. The Update Merchant Media API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure-5}


API Reference: `GET /merchants/{merchant_id}/images/{image_uuid}`

## Get Merchant Media {#get-merchant-media}

The Get Merchant Media API provides the ability to fetch all Merchant media based on the Merchant UUID (Universal Unique Identifier). Refer to the [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md) page for further information about each endpoint.

### Prerequisites {#prerequisites-5}

Refer to the following prerequisites for the customer to use this endpoint:

* The merchant data should exist for fetching media.

### Sequence diagram {#sequence-diagram-6}

Diagram merchant_medias

### Execution steps {#execution-steps-6}

1. The Merchant aggregator sends the GET request to Merchant Media API with path parameters Merchant UUID (Universal Unique Identifier) in the URL. Refer to [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
2. Mastercard Gateway validates the client request.
3. Mastercard Gateway routes the GET /merchants/{uuid}/images request to Merchant Media API in the case of valid request.
4. The request is validated with the application permissions using the key from the header.
5. The GET /merchants/{uuid}/images request fetches the Merchant media and returns a successful response (200).
6. The Merchant Media API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure-6}


API Reference: `GET /merchants/{merchant_id}/images`

## Add Merchant Geo Data {#add-merchant-geo-data}

The Add Merchant Geo Data API adds Merchant addresses. The addresses are later used to search for nearby offers. Refer to the [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md) page for further information about each endpoint.

### Prerequisites {#prerequisites-6}

Refer to the following prerequisites for the customer to use this endpoint:

* Adding addresses is only for existing Merchants so, the Merchant should be created to add addresses for Merchant using [merchant ingestion](https://developer.mastercard.com/eop-admin/documentation/use-cases/merchants/index.md) flow.

### Sequence diagram {#sequence-diagram-7}

Diagram merchant_address

### Execution steps {#execution-steps-7}

1. The Merchant aggregator sends the create request to Add Merchant Address API with path parameter Merchant UUID (Universal Unique Identifier) in the url and other parameters in the request payload at [API Reference](https://developer.mastercard.com/eop-admin/documentation/api-reference/index.md).
2. Mastercard Gateway validates the client request.
3. Gateway routes the POST /merchants/{uuid}/addresses request to Add Merchant Address API in the case of valid request.
4. The request is validated with the application permissions using the key from the header.
5. The POST /merchants/{uuid}/addresses request adds addresses to the Merchant and returns a successfully created response (201).
6. The Add Merchant Address API returns a response with a status code of 4XX/5XX in case of an invalid request.

### API structure {#api-structure-7}


API Reference: `GET /merchants/{merchant_id}/addresses`

## Next steps {#next-steps}

Use the Merchant and media images to create offers through [Offer Ingestion](https://developer.mastercard.com/eop-admin/documentation/use-cases/offers/index.md).
