技能 编程开发 SalesLoft API升级与迁移指南

SalesLoft API升级与迁移指南

v20260423
salesloft-upgrade-migration
本指南详细指导开发者如何将现有与SalesLoft API集成的代码迁移到最新版本。核心内容包括认证流程的升级,从旧的API密钥过渡到安全的OAuth 2.0认证,并演示了客户端凭证流的实现。此外,它还涵盖了新功能(如Cadence导入/导出)的采用,适用于进行大规模平台升级和维护复杂集成系统的开发人员。
获取技能
467 次下载
概览

SalesLoft Upgrade & Migration

Overview

SalesLoft REST API is versioned at v2 with no official SDK -- migrations involve endpoint changes, auth flow updates, and response schema changes. The Cadence Import/Export API was a major addition. Key migration: SalesLoft rebranded some endpoints and added OAuth client credentials flow.

Migration Scenarios

Legacy API Key to OAuth 2.0

// BEFORE: Static API key (being deprecated for partner apps)
const api = axios.create({
  headers: { Authorization: `Bearer ${process.env.SALESLOFT_API_KEY}` },
});

// AFTER: OAuth 2.0 with token refresh
class SalesloftOAuthClient {
  private tokenStore: { access: string; refresh: string; expiresAt: number };

  async getClient() {
    if (Date.now() > this.tokenStore.expiresAt * 1000 - 300_000) {
      await this.refreshToken();
    }
    return axios.create({
      baseURL: 'https://api.salesloft.com/v2',
      headers: { Authorization: `Bearer ${this.tokenStore.access}` },
    });
  }

  private async refreshToken() {
    const { data } = await axios.post('https://accounts.salesloft.com/oauth/token', {
      grant_type: 'refresh_token',
      refresh_token: this.tokenStore.refresh,
      client_id: process.env.SALESLOFT_CLIENT_ID,
      client_secret: process.env.SALESLOFT_CLIENT_SECRET,
    });
    this.tokenStore = {
      access: data.access_token,
      refresh: data.refresh_token,
      expiresAt: Math.floor(Date.now() / 1000) + data.expires_in,
    };
  }
}

Adding Client Credentials Flow

// Client credentials: server-to-server, no user interaction
// Recommended for background sync jobs
async function getServiceToken(): Promise<string> {
  const { data } = await axios.post('https://accounts.salesloft.com/oauth/token', {
    grant_type: 'client_credentials',
    client_id: process.env.SALESLOFT_CLIENT_ID,
    client_secret: process.env.SALESLOFT_CLIENT_SECRET,
  });
  return data.access_token; // No refresh token -- request new when expired
}

Cadence Import/Export API Adoption

// Export cadence (portable format -- can import into any SalesLoft instance)
const { data: exported } = await api.get(`/cadence_exports/${cadenceId}.json`);
// Returns agnostic content: steps, email templates, timing

// Import cadence into another instance
const { data: imported } = await api.post('/cadence_imports.json', {
  cadence_content: exported.data,
  settings: {
    name: 'Imported: Q1 Outbound',
    shared: false,
  },
});

Migration Checklist

  • Audit all endpoints used (search codebase for /v2/)
  • Check response fields consumed (SalesLoft may add/remove fields)
  • Test with staging OAuth app first
  • Update error handling for any new error codes
  • Verify rate limit costs haven't changed
  • Update webhook signature verification if format changed
  • Run integration tests against new version

Rollback

# Pin to previous behavior
git checkout -b rollback/salesloft-migration
git revert <migration-commit>
git push origin rollback/salesloft-migration

Error Handling

Change Impact Migration
API key deprecation Auth stops working Switch to OAuth 2.0
New required fields 422 on create Add new fields to payloads
Endpoint rename 404 on old path Update URL in client
Rate limit cost change Unexpected 429s Recalculate pagination budgets

Resources

Next Steps

For CI integration during upgrades, see salesloft-ci-integration.

信息
Category 编程开发
Name salesloft-upgrade-migration
版本 v20260423
大小 4.26KB
更新时间 2026-04-28
语言