> ## Documentation Index
> Fetch the complete documentation index at: https://docs.repediu.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Obter cliente (CRM)

> Ficha completa de um cliente da loja — contato, histórico de pedidos e engajamento

Detalha a **ficha completa** de um cliente da loja pelo `customerId` — vindo da [listagem](/crm-parceiro/clientes), de uma [conversão](/crm-parceiro/conversoes), de um [cupom](/crm-parceiro/cupons) ou de uma [avaliação](/crm-parceiro/avaliacoes).

<Warning>
  Diferente da listagem (pseudonimizada), o detalhe traz **dados pessoais**: nome, telefone, e-mail, data de nascimento e endereço. Trate esses campos conforme a LGPD — use-os apenas para a finalidade autorizada e não os armazene além do necessário.
</Warning>

Além da identificação, a resposta agrupa:

* **`address`** — endereço estruturado (`street`, `number`, `neighborhood`, `city`, `state`, `postalCode`, `country`), no mesmo formato usado pelo Open Delivery. `complement` hoje vem sempre `null` e `type`/`country` vêm sempre fixos em `delivery`/`BR`.
* **`orderHistory`** — produtos favoritos e canal de compra preferido. Ticket médio, intervalo entre compras e última compra **não estão mais aqui**: use esses campos na [listagem](/crm-parceiro/clientes), que já os traz por cliente.
* **`consentAndEngagement`** — opt-in de WhatsApp e se o cliente interagiu com a última comunicação. `orderOrigin` está no schema mas hoje vem sempre `null` (ainda não implementado).

<Note>
  O `customerId` **não é global**: ele pertence à loja. Um cliente de outra loja — ou inexistente — responde `404` com `Customer not found`.
</Note>

## Erros

| HTTP  | `code` no corpo | Quando acontece                                                                                            | O que fazer                                                         |
| ----- | --------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `401` | `UNAUTHORIZED`  | Token ausente, inválido ou expirado                                                                        | Gere um novo token em [Obter token](/open-delivery/obter-token)     |
| `403` | `FORBIDDEN`     | Token sem o escopo exigido pela rota                                                                       | Confirme as permissões da credencial com a Repediu                  |
| `404` | `NOT_FOUND`     | Merchant fora do escopo (`Merchant not found.`) ou cliente inexistente naquela loja (`Customer not found`) | Confirme o `customerId` em [Clientes (CRM)](/crm-parceiro/clientes) |

<Card title="Conversões" icon="arrow-right-left" href="/crm-parceiro/conversoes">
  As vendas atribuídas a campanhas — cada uma referencia um `customerId`.
</Card>


## OpenAPI

````yaml openapi.yaml GET /v1/stores/{merchantId}/customers/{customerId}
openapi: 3.0.1
info:
  title: Repediu — API de integração
  description: >-
    API de integração da Repediu: rotas Open Delivery 2.0 (capabilities CRM),
    dado bruto do CRM do parceiro (/v1/stores) e métricas agregadas
    (/v1/stores/.../metrics). A autenticação usa o fluxo client_credentials: o
    token identifica a aplicação integradora e dá acesso a todos os
    estabelecimentos (merchants) que ativaram a integração.
  version: v2
servers:
  - url: https://public-api.repediu.com.br
    description: Produção
security:
  - Bearer: []
paths:
  /v1/stores/{merchantId}/customers/{customerId}:
    get:
      tags:
        - CRM do parceiro
      summary: Obter cliente (CRM)
      description: >-
        Ficha completa de um cliente da loja — identificação, histórico de
        pedidos e engajamento. Diferente da listagem, inclui dados pessoais
        (nome, telefone, e-mail).
      operationId: getStoreCustomer
      parameters:
        - $ref: '#/components/parameters/MerchantIdPath'
        - name: customerId
          in: path
          required: true
          description: >-
            Identificador do cliente na loja, retornado em customerId na
            listagem.
          schema:
            type: integer
            format: int32
      responses:
        '200':
          description: Cliente encontrado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrmCustomerDetailResponse'
              example:
                id: 18452
                name: Maria Aparecida Souza
                phoneNumber: '5517999998888'
                email: maria.souza@example.com
                birthDate: '1990-05-12T00:00:00'
                address:
                  type: delivery
                  street: Rua das Palmeiras
                  number: '87'
                  complement: null
                  neighborhood: Jardim Europa
                  city: Jales
                  state: SP
                  postalCode: 15700-082
                  country: BR
                orderHistory:
                  favoriteProducts:
                    - productId: 101
                      productName: Pastel de Carne
                      totalQuantity: 22
                  purchaseChannel: iFood
                consentAndEngagement:
                  whatsappOptedIn: true
                  engagedWithLastCommunication: true
                  orderOrigin: null
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/InsufficientScope'
        '404':
          description: Merchant fora do escopo ou cliente inexistente naquela loja.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: NOT_FOUND
                message: Customer not found
                details: null
components:
  parameters:
    MerchantIdPath:
      name: merchantId
      in: path
      required: true
      description: Identificador (UUID) do merchant — o mesmo id de GET /od/v2/merchants.
      schema:
        type: string
        format: uuid
  schemas:
    CrmCustomerDetailResponse:
      type: object
      properties:
        id:
          type: integer
          format: int32
          description: Mesmo valor de customerId da listagem.
        name:
          type: string
          nullable: true
        phoneNumber:
          type: string
          nullable: true
        email:
          type: string
          nullable: true
        birthDate:
          type: string
          format: date-time
          nullable: true
        address:
          allOf:
            - $ref: '#/components/schemas/CustomerAddress'
          nullable: true
        orderHistory:
          type: object
          properties:
            favoriteProducts:
              type: array
              items:
                type: object
                properties:
                  productId:
                    type: integer
                    format: int32
                  productName:
                    type: string
                  totalQuantity:
                    type: number
            purchaseChannel:
              type: string
              nullable: true
        consentAndEngagement:
          type: object
          properties:
            whatsappOptedIn:
              type: boolean
            engagedWithLastCommunication:
              type: boolean
              nullable: true
            orderOrigin:
              type: string
              nullable: true
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: >-
            Código do erro (BAD_REQUEST, UNAUTHORIZED, FORBIDDEN, NOT_FOUND,
            INTERNAL_SERVER_ERROR).
        message:
          type: string
        details:
          type: array
          nullable: true
          description: Lista de mensagens de validação, quando aplicável.
          items:
            type: string
    CustomerAddress:
      type: object
      properties:
        type:
          type: string
          description: >-
            `delivery` (endereço de entrega) ou `billing` (endereço de
            cobrança).
          enum:
            - delivery
            - billing
        street:
          type: string
          nullable: true
        number:
          type: string
          nullable: true
        complement:
          type: string
          nullable: true
        neighborhood:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        state:
          type: string
          nullable: true
          description: UF (sigla do estado).
        postalCode:
          type: string
          nullable: true
        country:
          type: string
          description: Sempre `BR`.
  responses:
    Unauthorized:
      description: Token ausente, inválido ou expirado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: UNAUTHORIZED
            message: Invalid client credentials.
            details: null
    InsufficientScope:
      description: Token sem o escopo exigido pela rota.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: FORBIDDEN
            message: The access token does not have the required scope.
            details: null
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Token de acesso emitido por POST /od/v2/oauth/token (fluxo
        client_credentials). Envie no header Authorization como `Bearer
        <token>`.

````