---
agentTools:
  projectIndex: https://developers.dito.com.br/llms.txt
---

# Commit

Este endpoint foi projetado para validar o uso do cashback que foi posteriormente bloqueado pela rota de [lock](https://developers.dito.com.br/reference/rewardsservice_lockrewards). Após a confirmação, o cashback é registrado como usado e fica indisponível para [rollback](https://developers.dito.com.br/reference/rewardsservice_rollbackrewards) .

Para utilizar este endpoint, é necessário fornecer o lock\_token gerado durante o processo de [lock](https://developers.dito.com.br/reference/rewardsservice_lockrewards) , juntamente com o valor do cashback utilizado e o ID da compra que fará uso do cashback. Esse identificador deve estar presente no evento de compra enviado para a Dito.

Opcionalmente, é possível incluir dados personalizados que podem ser usados na segmentação do evento de consumo de cashback.

Ao confirmar a transação, algumas restrições devem ser observadas. Por exemplo, o saldo de cashback utilizado não pode ser negativo, o reward não pode estar expirado.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Dito Cashback APIs",
    "description": "You must have a JWT token to make authenticated requests to the API.\n Please visit [https://openapi.dito.com.br/docs](https://openapi.dito.com.br/docs/) for more information.",
    "version": "1.0"
  },
  "tags": [
    {
      "name": "RewardsService",
      "description": "Everything about reward redemption"
    }
  ],
  "paths": {
    "/api/v1alpha1/rewards:commit": {
      "post": {
        "summary": "Confirm the utilization of one or more rewards for a specified customer.",
        "description": "This endpoint is designed to validate the use of the cashback that was previously locked. Upon confirmation, the cashback is recorded as used and becomes unavailable for rollback.\n\nTo utilize this endpoint, you need to provide the lock_token generated during the locking process, along with the cashback value used and the unique identifier generated for the purchase. The purchase identifier must match the one intended for submission to Dito.\n\nOptionally, you can use custom data to send data that will be used in the segmentation of the cashack consumption event.\n\nCertain restrictions apply when committing. For instance, the cashback balance used must not be negative, the reward must not be expired, the lock must not have been generated more than 24 hours ago, and other similar criteria.",
        "operationId": "RewardsService_CommitRewards",
        "responses": {
          "200": {
            "description": "A successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "When an invalid request is sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/rpcStatus"
                },
                "examples": {
                  "response": {
                    "value": {
                      "code": 3,
                      "message": "validation error"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "When the authentication is failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/rpcStatus"
                },
                "examples": {
                  "response": {
                    "value": {
                      "code": 16,
                      "message": "authorization header missing"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "when it was not authorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/rpcStatus"
                },
                "examples": {
                  "response": {
                    "value": {
                      "code": 7,
                      "message": "forbidden"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/rpcStatus"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Brand",
            "description": "The brand label provided by us.",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/v1alpha1CommitRewardsRequest"
              }
            }
          },
          "required": true
        },
        "tags": [
          "RewardsService"
        ]
      }
    }
  },
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "servers": [
    {
      "url": "https://cashback.dito.com.br"
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "apiKey",
        "description": "Enter the token with the `Bearer: ` prefix, e.g. \"Bearer <jwt-token-here>\".",
        "name": "Authorization",
        "in": "header"
      }
    },
    "schemas": {
      "protobufAny": {
        "type": "object",
        "properties": {
          "@type": {
            "type": "string",
            "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n  value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n  URL, or have them precompiled into a binary to avoid any\n  lookup. Therefore, binary compatibility needs to be preserved\n  on changes to types. (Use versioned type names to manage\n  breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
          }
        },
        "additionalProperties": {},
        "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n    Foo foo = ...;\n    Any any;\n    any.PackFrom(foo);\n    ...\n    if (any.UnpackTo(&foo)) {\n      ...\n    }\n\nExample 2: Pack and unpack a message in Java.\n\n    Foo foo = ...;\n    Any any = Any.pack(foo);\n    ...\n    if (any.is(Foo.class)) {\n      foo = any.unpack(Foo.class);\n    }\n    // or ...\n    if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n      foo = any.unpack(Foo.getDefaultInstance());\n    }\n\n Example 3: Pack and unpack a message in Python.\n\n    foo = Foo(...)\n    any = Any()\n    any.Pack(foo)\n    ...\n    if any.Is(Foo.DESCRIPTOR):\n      any.Unpack(foo)\n      ...\n\n Example 4: Pack and unpack a message in Go\n\n     foo := &pb.Foo{...}\n     any, err := anypb.New(foo)\n     if err != nil {\n       ...\n     }\n     ...\n     foo := &pb.Foo{}\n     if err := any.UnmarshalTo(foo); err != nil {\n       ...\n     }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n    package google.profile;\n    message Person {\n      string first_name = 1;\n      string last_name = 2;\n    }\n\n    {\n      \"@type\": \"type.googleapis.com/google.profile.Person\",\n      \"firstName\": <string>,\n      \"lastName\": <string>\n    }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n    {\n      \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n      \"value\": \"1.212s\"\n    }"
      },
      "rpcStatus": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "format": "int32",
            "description": "The status code, which should be an enum value of\n[google.rpc.Code][google.rpc.Code]."
          },
          "message": {
            "type": "string",
            "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized\nby the client."
          },
          "details": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/protobufAny"
            },
            "description": "A list of messages that carry the error details.  There is a common set of\nmessage types for APIs to use."
          }
        },
        "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)."
      },
      "v1alpha1CommitRewardsRequest": {
        "type": "object",
        "properties": {
          "lockId": {
            "type": "string",
            "example": "",
            "description": "Deprecated."
          },
          "lockToken": {
            "type": "string",
            "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjYXNoYmFja192YWx1ZV9pbl9jZW50cyI6MTAwLCJjdXN0b21lcl9pZCI6ImN1c3RvbWVySWQiLCJleHAiOjE3MDU0MjQ5MTEsImxvY2tfaWQiOiIxMjMiLCJvcmRlcl92YWx1ZV9pbl9jZW50cyI6NTAwMDAwfQ.aNRtKU5S0FR2_JhZzDvc4DdqWKND5wriRTNX_aC9xzs",
            "description": "Lock identifier generated for rewards."
          },
          "valueUsed": {
            "type": "string",
            "example": 60.99,
            "description": "Cashback value used on the order.",
            "maximum": 99999999.99
          },
          "orderId": {
            "type": "string",
            "example": "ORDER123121",
            "description": "Order ID."
          },
          "customData": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Custom data, a map of string to string value."
          }
        },
        "title": "CommitRewardsRequest",
        "required": [
          "lockToken",
          "valueUsed",
          "orderId"
        ]
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 106,
      "1": 178,
      "2": 157,
      "3": 24,
      "4": 181,
      "5": 5,
      "6": 177,
      "7": 176,
      "8": 187,
      "9": 191,
      "10": 125,
      "11": 82
    }
  }
}
```