PartnerShare
品牌主
营销方式
联盟增长找外部推广者来卖你的产品 推荐营销(老带新计划)让老用户带来新用户
使用案例
AI 工具站教程测评带来订阅转化 IP 代理服务站追踪首单、续费与佣金 电商独立站用分销和内容测评提升转化 指纹浏览器触达跨境和多账号运营人群
推广者 推广市场
导航站
跨境电商导航 AIGC 导航 全球 IP 代理导航 精选产品
价格
资源
博客增长方法、渠道拆解与产品更新 帮助中心接入文档、账户设置与常见问题 最新资讯出海营销动态与行业热点
品牌主
营销方式 联盟增长 推荐营销(老带新计划) 使用案例 AI 工具站 IP 代理服务站 电商独立站 指纹浏览器
推广者 推广市场
导航站
跨境电商导航 AIGC 导航 全球 IP 代理导航 精选产品
价格
资源
博客 帮助中心 最新资讯

选择入口

请选择适合您的身份入口。

管理产品和联盟计划 品牌主 创建产品、设置佣金规则并管理推广转化。 创建品牌主账号→ 发现好产品赚取佣金 推广者 发现高佣产品,一键获取专属推广链接。 免费入驻推广市场→ 发布产品资讯获取曝光 内容发布方 提交产品并发布资讯,获取中文内容曝光。 进入内容发布平台→

预约 1v1 演示

产品顾问将在 1 个工作日内与你约定 30 分钟在线演示,带你搭好第一个推广计划。

提交后我们会尽快与你联系。

想先自己体验?免费注册 →

提交即表示你同意 PartnerShare 为安排产品演示而联系你。

微信扫码联系

使用微信扫描二维码添加企业微信,产品顾问会尽快与你联系。

PartnerShare 企业微信二维码 PartnerShare Telegram 二维码 保存图片到本地 CHAT ON TELEGRAM
✓

申请已提交

我们会尽快联系你,安排演示和接入建议。你也可以先注册账号体验产品。

Skip to content

Getting Started

4
  • How to Launch Your Affiliate Program on PartnerShare
  • How to Create a Referral Program
  • What Is Referral Marketing / “Old-Bring-New” Program
  • What is Affiliate Marketing?
合作伙伴管理 - PartnerShare

Campaign Operations

5
  • Checking Partner Withdrawal Status
  • Withdrawal Methods Supported for Partners
  • Affiliate Management
  • Product Management
  • Campaign Management
支付与交易 - ParterShare

Payments&Transactions

2
  • Auto-Payout
  • Commission Settlement
技术集成 - PartnerShare

Account Management

2
  • Business Certification Prompts
  • Team Management
技术集成 - PartnerShare

Technical Integration

5
  • Embedding PartnerShare into Your Product
  • Conversion Event Postback
  • Click-Tracking SDK Integration
  • API Authentication & Signature Mechanism
  • PartnerShare Product-Authorized Login Integration Guide
常见问题 - PartnerShare

Frequently Asked Questions

2
  • Withdrawal FAQ
  • Legacy Help Center Entrance
快速入门 - PartnerShare

Changelog

2
  • Changelog – 2026.03.05
  • Changelog – 2026.05.15
View Categories
  • 帮助中心
  • Technical Integration
  • API Authentication & Signature Mechanism

API Authentication & Signature Mechanism

PartnerShare API Authentication

This article explains the server-side authentication method for PartnerShare’s open API. Integrators must include an API Key, a second-precision timestamp, and a signature with every request. PartnerShare recalculates the signature server-side using the API Secret to validate the request, preventing forgery, replay, or unauthorized calls.

Key concepts: API Key (identity), API Secret (server-side signing), 5-minute time window, SHA256

1. Overview

PartnerShare’s open API uses API Key + API Secret + Timestamp + Signature for authentication by default. The API Key identifies the calling product; the API Secret is used only to generate the signature server-side and is never sent directly with the request.

Confirm caller identity: X-Api-Key identifies the product/tenant, ensuring the request comes from an authorized product.

Prevent request forgery: The signature is generated using the API Secret — attackers who know the API Key still cannot construct a valid signature.

Reduce replay risk: X-Api-Timestamp is only valid within a 5-minute window; expired requests are rejected.

Security note: The API Secret must be kept on the server side. It must never be exposed in browsers, mini-programs, mobile apps, public repositories, or shared Postman environments.

2. Getting your API Key and API Secret

In the PartnerShare dashboard, go to the relevant product’s Developer Integration or Advanced Settings page to get that product’s API Key and API Secret.

Field responsibilities: The API Key is sent in the request header to identify the calling product; the API Secret is only used locally to compute the signature and is never transmitted in plaintext.

3. Request header conventions

When calling an authenticated open API endpoint, include the following headers:

HeaderRequiredDescription
X-Api-KeyYesThe API Key PartnerShare assigned to your product, used to identify the calling product.
X-Api-TimestampYesSecond-precision timestamp. The server validates it’s within the allowed time window.
X-Api-SignYesThe SHA256 signature generated per this document’s rules.
Content-TypeYesapplication/json recommended.

Header example: #

http

POST /api/open/v1/track/conversion HTTP/1.1
Host: api-service.partnershare.net
Content-Type: application/json
X-Api-Key: pk_xxxxxxxxxxxxxxxxxxxxx
X-Api-Timestamp: 1776677721
X-Api-Sign: 8473ee71d083d9d1650c0e9081b5777d5b6cde2508521d5322d603a007214afd

4. Signature rules

PartnerShare’s signature only uses request parameter field names in the calculation — not the field values. Header fields do not participate in the signature either.

Collect request parameters: Merge top-level field names from the URL query, form body, and JSON body.

Lowercase all field names: e.g., Product_Key becomes product_key for signing purposes.

Sort naturally: The sort order must match the server’s — PHP can use SORT_NATURAL.

Join with &: e.g., extra&product_key&target_product_key&user_id.

Append timestamp and API Secret: The final string is joined_field_names + timestamp + api_secret.

Compute SHA256: Hash the final string with SHA256 to get the hex signature.

4.1 Signature formula #

text

sha256(sorted_lowercase_param_keys_joined_by_ampersand + timestamp + api_secret)

4.2 Worked example #

Request parameters:

json

{
  "product_key": "your_product_key",
  "target_product_key": "target_product_key",
  "user_id": "user_10001",
  "extra": {
    "locale": "zh"
  }
}

Field names included in the signature:

text

product_key
target_product_key
user_id
extra

Sorted and joined:

text

extra&product_key&target_product_key&user_id

Assume:

text

timestamp = 1776677721
api_secret = sk_your_api_secret

Final string to be signed:

text

extra&product_key&target_product_key&user_id1776677721sk_your_api_secret

5. Signature code examples

5.1 JavaScript #

javascript

function makeSign(params, timestamp, apiSecret) {
  const keys = Object.keys(params)
    .map((key) => key.toLowerCase())
    .sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));

  const signString = keys.join('&') + timestamp + apiSecret;

  return CryptoJS.SHA256(signString).toString(CryptoJS.enc.Hex);
}

5.2 PHP #

php

<?php

function makeSign(array $params, string $timestamp, string $apiSecret): string
{
    $keys = array_map('strtolower', array_keys($params));
    sort($keys, SORT_NATURAL);

    $signString = implode('&', $keys) . $timestamp . $apiSecret;

    return hash('sha256', $signString);
}

5.3 Go #

go

package main

import (
    "crypto/sha256"
    "fmt"
    "sort"
    "strings"
)

func MakeSign(params map[string]interface{}, timestamp string, apiSecret string) string {
    keys := make([]string, 0, len(params))
    for key := range params {
        keys = append(keys, strings.ToLower(key))
    }

    sort.Strings(keys)

    signString := strings.Join(keys, "&") + timestamp + apiSecret
    sum := sha256.Sum256([]byte(signString))

    return fmt.Sprintf("%x", sum)
}

5.4 Python #

python

import hashlib

def make_sign(params: dict, timestamp: str, api_secret: str) -> str:
    keys = sorted([key.lower() for key in params.keys()])
    sign_string = "&".join(keys) + timestamp + api_secret
    return hashlib.sha256(sign_string.encode("utf-8")).hexdigest()

6. Full request example

Below is an example of the headers and body structure for a signup event postback request. Different endpoints may have different body fields, but the signature method is the same.

http

POST /api/open/v1/track/conversion HTTP/1.1
Host: api-service.partnershare.net
Content-Type: application/json
X-Api-Key: pk_xxxxxxxxxxxxxxxxxxxxx
X-Api-Timestamp: 1776677721
X-Api-Sign: 8473ee71d083d9d1650c0e9081b5777d5b6cde2508521d5322d603a007214afd

json

{
  "event_name": "signup",
  "invited_user_id": "user_10001",
  "invite_code": "abc123"
}

Field names signed in this example: event_name, invited_user_id, invite_code, sorted and joined as event_name&invite_code&invited_user_id.

7. Common errors & troubleshooting

7.1 Why do I get “API Key or signature cannot be empty”? #

Usually the request header is missing X-Api-Key, X-Api-Timestamp, or X-Api-Sign. Confirm the header names are spelled correctly and that no gateway/proxy is stripping custom headers.

7.2 Why do I get “invalid signature”? #

Check specifically: whether you used the API Secret (not the API Key) to sign; whether field names are lowercased; whether the sort order matches; and whether the fields you signed exactly match the actual top-level fields in the request body.

7.3 Why does my signature work locally but fail in production? #

A common cause is that the serialization format changes in production — e.g., JSON locally but form-encoded in production — or a reverse proxy alters the request body. We recommend logging the actual top-level field names sent to PartnerShare and comparing them.

7.4 How long is the timestamp valid? #

Currently 5 minutes. Use a second-precision timestamp, and make sure your server clock is synced to standard time.

7.5 Can the API Secret be placed in the frontend? #

No. If the API Secret is exposed, anyone can forge valid requests. Always generate the signature server-side; the frontend should only call your own backend.

8. Best practices

  • Keep the API Secret on the server only — never in frontend code, mobile app binaries, or public config.
  • Generate a fresh timestamp and signature for every request — never reuse a previous signature.
  • Log the list of field names used for signing before signing, to make debugging easier.
  • Use different API Key/Secret pairs for production and test environments.
  • If you suspect the API Secret has leaked, reset it immediately in the dashboard and update your server-side config.

Updated on 26/08/2026

Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
PartnerShare Product-Authorized Login Integration GuideClick-Tracking SDK Integration
大纲
  • Header example:
  • 4.1 Signature formula
  • 4.2 Worked example
  • 5.1 JavaScript
  • 5.2 PHP
  • 5.3 Go
  • 5.4 Python
  • 7.1 Why do I get "API Key or signature cannot be empty"?
  • 7.2 Why do I get "invalid signature"?
  • 7.3 Why does my signature work locally but fail in production?
  • 7.4 How long is the timestamp valid?
  • 7.5 Can the API Secret be placed in the frontend?
PartnerShare

帮出海 SaaS 找到推广者、跑起联盟、放大用户推荐。先免费接入,跑出数据再升级。 Find promoters, run affiliate, and turn user referrals into a tracked growth channel. Start free, upgrade after data.

产品 Product

  • 联盟增长Affiliate growth
  • 邀返系统Referral program
  • 推广市场Marketplace
  • 价格Pricing

资源 Resources

  • 博客Blog
  • 帮助中心Help center
  • 最新资讯Latest news

导航站 Directory

  • 跨境电商导航Cross-border Ecommerce Directory
  • AIGC 导航AIGC Directory
  • 全球 IP 代理导航Global IP Proxy Directory
  • 精选产品Featured Products

联系方式 Contact

联系Contact business@partnershare.net
PartnerShare 公众号二维码
in XHS

版权所有© 广州标品科技创新有限公司, SAASBASE PTE. LTD. 丨 粤ICP备2022116046号 © Guangzhou Biaopin Technology Innovation Co., Ltd., SAASBASE PTE. LTD. · ICP 2022116046

服务协议Terms of Service 隐私政策Privacy