Skip to main content
Question

Provisioning API 500 Error , Need Help Creating API User

  • November 5, 2025
  • 1 reply
  • 15 views

Support,

I'm integrating the Collection API for my e-commerce platform and unable to create API Users via the Provisioning API.

Issue:
- Endpoint: POST https://sandbox.momodeveloper.mtn.com/v1_0/apiuser
- Error: HTTP 500 Server Error
- Subscription: Collection API (Sandbox)
- Tried: Both Primary and Secondary keys

Questions:
1. Is the Provisioning API available for Collection API subscriptions?
2. How can I create API Users for authentication?
3. Can I use Consumer Key/Secret instead? If so, where do I find them?

Details:
- Country: Cameroon 
- Product: Collection API (Sandbox)
- Subscription Keys: ac1e3966... / 584fb04d...

Please advise on the correct authentication method for Collection API token generation.

Thank you,
 

1 reply

  • New Member
  • November 23, 2025

Hello Patrice,

Yes, the Provisioning API is the right way to create API Users for the collection api 

  1. Create an API User via the Provisioning API (/v1_0/apiuser)

  2. Generate an API Key for that user (/v1_0/apiuser/{referenceId}/apikey)

  3. Use X-Reference-Id:APIKey as a Basic Auth pair to get an access token

Here’s how I’m doing it with Node.js + axios, and it works on sandbox:

 

/**
 * Step 3 — Create an API User
 */
import axios from "axios";
import { v4 as uuidv4 } from "uuid";

const MOMO_BASE_URL = "https://sandbox.momodeveloper.mtn.com";
const SUBSCRIPTION_KEY = process.env.MOMO_SUBSCRIPTION_KEY; // Collection API (Sandbox)
const CALLBACK_DOMAIN = "your-callback-domain.com"; // must match providerCallbackHost

export async function createApiUser() {
  const referenceId = uuidv4();
  const url = `${MOMO_BASE_URL}/v1_0/apiuser`;
  console.log("Creating API User with URL:", url);

  try {
    const res = await axios.post(
      url,
      {
        providerCallbackHost: CALLBACK_DOMAIN, // optional but recommended to get notified when your customer validate the payment 
      },
      {
        headers: {
          "Ocp-Apim-Subscription-Key": SUBSCRIPTION_KEY,
          "X-Reference-Id": referenceId,
          "Content-Type": "application/json",
        },
      }
    );

    console.log("✅ API User created:", referenceId, res.status);
    return referenceId;
  } catch (error) {
    console.error("❌ Error creating API User:", error.response?.status, error.response?.data);
    throw error;
  }
}