Skip to content

entries.create()

Add a new content entry to a feed.

Signature

entries.create(feedId: string, input: CreateEntryInput): Promise<Entry>

Parameters

feedId

  • Type: string
  • Required: Yes
  • Description: The UUID of the feed to add the entry to

input

  • Type: CreateEntryInput
interface CreateEntryInput {
  // Either provide raw content (SDK will base64 encode it)
  content?: string | Buffer | Blob | File | ArrayBuffer | object;
  // OR provide pre-encoded base64 content (for advanced users)
  content_base64?: string;
  mime_type?: string;                  // Auto-detected if not provided
  title?: string;                      // Entry title
  description?: string;                // Entry description
  metadata?: Record<string, any>;      // Additional metadata
  tags?: string[];                     // Entry tags
  is_free?: boolean;                   // Free access (default: true)
  expires_at?: number;                 // Unix timestamp expiration
  price?: {                           // Price for paid entries
    amount: string;
    currency: string;
  };
}

Returns

  • Type: Promise<Entry>
interface Entry {
  id: string;
  feed_id: string;
  cid: string;
  mime_type: string;
  title?: string | null;
  description?: string | null;
  metadata?: string | null;
  tags: string[] | null;
  is_free: boolean;
  expires_at?: number | null;
  is_active: boolean;
  total_purchases: number;
  total_revenue: string;
  pinata_upload_id?: string | null;
  piid?: string | null;
  created_at: number;
  updated_at: number;
}

Usage

Basic Example

const entry = await grapevine.entries.create(feedId, {
  content: 'This is my content',
  title: 'My First Entry'
});
 
console.log('Entry created:', entry.id);

Free Entry

// Create a free preview entry
const freeEntry = await grapevine.entries.create(feedId, {
  title: 'Free Preview',
  content: 'This content is available for free to everyone',
  is_free: true,
  tags: ['preview', 'free']
});

With Description

// Entry with description
const detailedEntry = await grapevine.entries.create(feedId, {
  title: 'Detailed Guide',
  content: 'This is the full content of the guide...',
  description: 'A comprehensive guide to blockchain technology',
  tags: ['blockchain', 'guide']
});

JSON Content

// Create JSON data entry - can pass object directly
const jsonData = {
  type: 'market-data',
  symbol: 'BTC',
  price: 50000,
  volume: 1000000
};
 
const dataEntry = await grapevine.entries.create(feedId, {
  title: 'Market Update',
  content: jsonData,  // Pass object directly
  mime_type: 'application/json',
  tags: ['data', 'market']
});

Markdown Content

// Create markdown entry
const markdownContent = `
# Technical Analysis
 
## Overview
Today's market shows...
 
- Point 1
- Point 2
- Point 3
`;
 
const mdEntry = await grapevine.entries.create(feedId, {
  title: 'Daily Analysis',
  content: markdownContent,
  mime_type: 'text/markdown',
  tags: ['analysis', 'daily']
});

Behind the Scenes

This method:

  1. Validates input parameters
  2. Auto-detects MIME type if not provided
  3. Gets authentication headers (nonce + signature)
  4. Makes POST request to /v1/feeds/{feedId}/entries
  5. Handles 402 payment automatically
  6. Stores content on IPFS
  7. Returns created entry with cid (IPFS content identifier)

Error Handling

try {
  const entry = await grapevine.entries.create(feedId, {
    content: 'New content',
    title: 'New Entry'
  });
} catch (error) {
  if (error.message.includes('404')) {
    console.error('Feed not found');
  } else if (error.message.includes('403')) {
    console.error('Not authorized - you can only add to your own feeds');
  } else if (error.message.includes('402')) {
    console.error('Payment failed');
  } else if (error.message.includes('400')) {
    console.error('Invalid input');
  } else {
    console.error('Error:', error.message);
  }
}

Notes

  • Authentication: Required - must be feed owner
  • Payment: Requires x402 micropayment (handled automatically)
  • MIME Type: Auto-detected from content if not specified
  • Private IPFS Storage: Content stored on Private IPFS, returns cid
  • Ownership: Can only add entries to feeds you own
  • Free Entries: Mark is_free: true for public access without payment

Related