Docs

Drafts API

Manage drafts - save incomplete posts for later completion and publishing.

GET/social/drafts

Get All Drafts

Retrieve all saved drafts for the workspace with optional filtering and pagination.

Query Parameters

ParameterTypeRequiredDescription
pagenumberNoPage number for pagination (default: 1)
limitnumberNoNumber of drafts per page (default: 20, max: 100)
searchstringNoSearch in draft title and content

Response

{
  "success": true,
  "data": {
    "drafts": [
      {
        "id": "draft_123",
        "title": "My Draft Post",
        "content": {
          "text": "This is a draft post content...",
          "media": [
            {
              "type": "image",
              "url": "https://api.zyhap.com/uploads/media/draft_image.jpg",
              "filename": "image.jpg"
            }
          ]
        },
        "platforms": [
          {
            "platformId": "facebook",
            "pageId": "page_456",
            "pageName": "My Business Page"
          }
        ],
        "createdAt": "2024-01-01T10:00:00Z",
        "updatedAt": "2024-01-01T11:30:00Z",
        "tags": ["marketing", "promotion"]
      }
    ],
    "pagination": {
      "current": 1,
      "total": 5,
      "pages": 1,
      "limit": 20
    }
  }
}
POST/social/drafts

Create Draft

Save a post as a draft for later completion and publishing.

Request Body

{
  "title": "My Draft Post",
  "content": {
    "text": "This is incomplete content...",
    "media": [
      {
        "type": "image",
        "url": "https://api.zyhap.com/uploads/media/image.jpg",
        "filename": "image.jpg"
      }
    ]
  },
  "platforms": [
    {
      "platformId": "facebook",
      "pageId": "page_456",
      "pageName": "My Business Page"
    }
  ],
  "tags": ["marketing", "promotion"]
}

Response

{
  "success": true,
  "data": {
    "draft": {
      "id": "draft_123",
      "title": "My Draft Post",
      "content": {
        "text": "This is incomplete content...",
        "media": [
          {
            "type": "image",
            "url": "https://api.zyhap.com/uploads/media/image.jpg",
            "filename": "image.jpg"
          }
        ]
      },
      "platforms": [
        {
          "platformId": "facebook",
          "pageId": "page_456",
          "pageName": "My Business Page"
        }
      ],
      "createdAt": "2024-01-01T10:00:00Z",
      "updatedAt": "2024-01-01T10:00:00Z",
      "tags": ["marketing", "promotion"]
    }
  }
}
PUT/drafts/{id}

Update Draft

Update an existing draft with new content or metadata.

Path Parameters

ParameterTypeDescription
idstringThe draft ID to update

Request Body

{
  "title": "Updated Draft Title",
  "content": {
    "text": "Updated content with more details...",
    "media": [
      {
        "type": "image",
        "url": "https://api.zyhap.com/uploads/media/updated_image.jpg",
        "filename": "updated_image.jpg"
      }
    ]
  },
  "tags": ["marketing", "promotion", "updated"]
}
DELETE/drafts/{id}

Delete Draft

Permanently delete a draft. This action cannot be undone.

Response

{
  "success": true,
  "message": "Draft deleted successfully"
}
POST/drafts/{id}/publish

Publish Draft

Convert a draft into a scheduled post. This moves the content from drafts to the posts queue.

Request Body

{
  "publishDate": "2024-01-02T14:00:00Z",
  "timezone": "America/New_York",
  "finalizeContent": {
    "text": "Final version of the post content...",
    "media": [
      {
        "type": "image",
        "url": "https://api.zyhap.com/uploads/media/final_image.jpg",
        "filename": "final_image.jpg"
      }
    ]
  }
}

Response

{
  "success": true,
  "data": {
    "post": {
      "id": "post_456",
      "status": "scheduled",
      "publishDate": "2024-01-02T14:00:00Z",
      "platforms": [
        {
          "platformId": "facebook",
          "pageId": "page_456",
          "status": "scheduled"
        }
      ]
    },
    "message": "Draft published successfully"
  }
}

Common Use Cases

📝 Content Planning

Save incomplete posts while working on content strategy and campaign planning.

🎨 Creative Workflow

Store multiple versions and ideas before finalizing content for publication.

👥 Team Collaboration

Share drafts between team members for review and approval before scheduling.

🔄 Template Management

Create reusable content templates that can be duplicated and customized.

Workflow Example

Here's a complete draft-to-publish workflow:

// 1. Create a draft while writing
const draftResponse = await fetch('/api/v1/public/marketing/drafts', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key',
    'X-Workspace-ID': 'your_workspace_id'
  },
  body: JSON.stringify({
    title: 'Marketing Campaign Draft',
    content: {
      text: 'Initial idea for campaign...',
      media: []
    },
    platforms: [{
      platformId: 'facebook',
      pageId: 'page_123'
    }],
    tags: ['campaign', 'draft']
  })
});

const { data: { draft } } = await draftResponse.json();

// 2. Update draft as content evolves
await fetch(`/api/v1/public/marketing/drafts/${draft.id}`, {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key',
    'X-Workspace-ID': 'your_workspace_id'
  },
  body: JSON.stringify({
    title: 'Final Marketing Campaign',
    content: {
      text: 'Complete campaign content with call-to-action...',
      media: [{ type: 'image', url: 'final-image.jpg' }]
    }
  })
});

// 3. Publish when ready
await fetch(`/api/v1/public/marketing/drafts/${draft.id}/publish`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key',
    'X-Workspace-ID': 'your_workspace_id'
  },
  body: JSON.stringify({
    publishDate: '2024-01-15T10:00:00Z',
    timezone: 'America/New_York'
  })
});