You can install the package with the following command:
npm install microsoft-partnercenter
or
yarn add microsoft-partnercenter
or
pnpm install microsoft-partnercenter
Initialize with Client ID and Client Secret Auth & Partner Domain:
import { MicrosoftPartnerCenter } from "microsoft-partnercenter"
const msPartnerCenter = new MicrosoftPartnerCenter({
partnerDomain: "partner.onmicrosoft.com",
authentication: {
clientId: "1",
clientSecret: "1",
},
})
Initialize with Client ID, Client Secret, and Tenant ID:
import { MicrosoftGraphApi } from "microsoft-partnercenter"
const msGraphApi = new MicrosoftGraphApi({
tenantId: "your-tenant-id",
authentication: {
clientId: "1",
clientSecret: "1",
},
})
await msPartnerCenter.getAllCustomers()
const customerId = "123"
const billingCycle = "monthly"
const lineItems = [
{
offerId: "1",
quantity: 16,
termDuration: "P1M",
},
]
await msPartnerCenter.createOrder(customerId, billingCycle, lineItems)
const relationship = await msGraphApi.createGDAPRelationship({
displayName: "My GDAP Relationship",
partner: {
tenantId: "partner-tenant-id",
},
customer: {
tenantId: "customer-tenant-id",
},
accessDetails: {
unifiedRoles: ["Directory Readers"],
},
duration: "P90D",
})
const relationships = await msGraphApi.getAllGDAPRelationships()
const domain = await msGraphApi.createDomain("example.com")
const domains = await msGraphApi.getAllDomains()
Both the Partner Center API and Graph API support authentication using client credentials (client ID and client secret). The SDK handles token management and renewal automatically.
The SDK includes built-in error handling and will automatically retry on certain errors (e.g., 401 Unauthorized). You can configure retry behavior in the config object:
const msPartnerCenter = new MicrosoftPartnerCenter({
// ... other config
conflict: {
retryOnConflict: true,
retryOnConflictDelayMs: 1000,
maximumRetries: 3,
},
})
For more detailed information about available methods and their parameters, please refer to the TypeScript definitions included with this package.
Contributions are welcome! Please feel free to submit a Pull Request