Skip to content

Quickstart

This walkthrough validates authentication and lead creation in staging. You need credentials for that environment and curl; the examples also use jq to read the token and identifier.

  1. Configure the environment

    Keep credentials out of your source code:

    Terminal window
    export CREDITAS_AUTH_URL="https://auth-staging.creditas.com.br/api/affiliate_clients/tokens"
    export AUTO_FINANCING_BASE_URL="https://stg-api.creditas.io/mx/b2b/autofin"
    export CREDITAS_CONSUMER_KEY="<consumer-key>"
    export CREDITAS_CONSUMER_SECRET="<consumer-secret>"
  2. Generate an access token

    Terminal window
    export CREDITAS_ACCESS_TOKEN="$(
    curl --fail-with-body --silent --show-error \
    --request POST "$CREDITAS_AUTH_URL" \
    --header "Accept: application/json" \
    --header "Accept-Version: v1" \
    --header "Content-Type: application/json" \
    --data "{
    \"consumer_key\": \"$CREDITAS_CONSUMER_KEY\",
    \"consumer_secret\": \"$CREDITAS_CONSUMER_SECRET\"
    }" |
    jq -er '.access_token'
    )"
  3. Create a test lead

    Terminal window
    curl --fail-with-body --silent --show-error \
    --request POST "$AUTO_FINANCING_BASE_URL/api/leads" \
    --header "Authorization: Bearer $CREDITAS_ACCESS_TOKEN" \
    --header "Content-Type: application/json" \
    --data '{
    "phone": "9128463859",
    "email": "pq-approved@creditas.com",
    "downPayment": 30000,
    "term": 24,
    "externalAutoId": "MLM1496685003"
    }' |
    tee lead.json

    A successful response returns 201 Created and a UUID id. Keep it for the next operations:

    Terminal window
    export AUTO_FINANCING_LEAD_ID="$(jq -er '.id' lead.json)"
  4. Continue the application

    Save the applicant’s personal information, complete the address, financial, and vehicle data, then request the PIN and offer.

Review the API flow to understand the complete lead lifecycle.